£ 2.50 Sterling

FOR THE

• Calling the CLI from AmigaBASIC by Jim Butterfield • Build a 68020/68881 speed-up board for the 1000! by Brad Fowles • What's changed in Fonts with 1.3 by Betty Clay • The future of Amiga microcomputing by David Wood • Creating run-time libraries by Steve Simpson • Modula-2 programming techniquesby Clark Williams • Using TCI's M2AMIGA by Anthony Bryant • Examples of shell programming by John Faichney

Femme Blue by Derek Grime TM

UPGRADE

TM THE RELATIONAL THAT'S AS EASY TO USE AS A VCR

• Powerful sorting and searching facilities on any field: up to 999 key fields ■ VCR style control panel gives easy access to unlimited files, fields and records J ■ 3 ways of viewing data to cover entry, review and comparison EW r ■ Set up and change file definitions quickly for system flexibility N QR\t • Define and print multi-file reports with Superbase Query function PERSAL • Include images and text as external files within your database record for cataloguing ■ Superbase Personal: Multi-file relational power at a flat-file price UPGRADE AT A DISCOUNT WHEN YOU NEED TO TM POWERFUL DATABASE WITH BUILT-IN TEXT PROCESSING %sal All the features of Superbase Personal PLUS • Text Editor for creation of letters and documents: editing options include cut and paste • Improved data handling facilities including batch for speedy data entry • Keyboard controls for easy editing • Time field type and additional validation options including cross-file lookup for accurate data PiiISC% i • Mail-merge facility for producing personalized letters and mailings • Built-in telecommunications for swift data transfer ■ Superbase Personal 2: Full-featured file management at your fingertips UPGRADE AT A DISCOUNT WHEN YOU NEED TO THE MOST POWERFUL DATABASE FOR THE AMIGA COMPUTER • Database management language (DML). Superbase own BASIC-style programming language ~+ Over 250 high-level commands, and other powerful features such as arrays, looping constructs and branching • Create sophisticated custom programs and applications including user defined menus • Report generator for ease of set-up and output of reports • Intelligent Forms Editor enables you to generate multi-file applications without the need for programming • Automatic transaction processing lets you reproduce standard business forms PRO'fESSIONAI • Extensive programmable communications facilities • Superbase Professional: Powerful programmable database that's fun to learn and easy to use

SUPERBASE PROFESSIONAL • BUSINESS GRAPHICS • TIME MANAGEMENT AND SUPERPLAN NOW SUPPORT Tm ■ Full featured spreadsheet environment that tracks time, resources and money to give a complete ARexx picture of your project plans •■ Print wall planning charts, Gantt charts; do critical path analysis u p / ■ Graphics facility to visually portray your data in over 100 different graph styles and options • Sideways printing, full color output to extensive range of printers and plotters • Fully programmable, Lotus 1.23 and dBase file compatible • Works stand alone or with Superbase to provide superb productivity environment ■ Superplan: The Fourth Dimension

Precision Software Limited Available from your dealer 6 Park Terrace Precision Worcester Park or call (01) 330 7166 Surety KT4 7JZ J Software Tel: (01) 330 7166. Fax: (Oil 330 2089

AMIGA Commodore PCs HARD DRIVES ~i PCIOIII £859.00 Incredible Value ~ PC20 III £1259.00 20MB £499.95 PC40-20 £1959.00 DIGIPRO PC40-40 E2549.00 40MB £599.95 PC60-40 £4949.00 60MB 2699.95 PC60-80 £6249.00

Modulator Printer £24.95 L Cables £7.99 3.5" External Drives AMIGA A2000 AMIGA A500 lus 1084 NOW ONLY £1,399.00 IN £99.95 £399.00

AMIGA A500 Sony Branded1 f rib PLUS 3.5" DS/DD disks Okimate 20 Box of 10 Ing_ P&P Colour Printer opening offer (0703) Including FREE printer cable €14.99 703030 ONLY £519.00 Your Southern and Amiga + PC Unbranded Disks Dealer invites you to visit our 3.5" DS/DD new showroom in Southampton where we will be happy to 10 for only demonstrate our extensive sees range of hardware and including free copy of VirusX software. Price incudes Postage & Packing

DIGIPRO LTD Authorized Commodore Business Centre Enterprise House, Howards Grove, Southampton 501 5RP i Okimate 20 Locking Disk Boxes Colour printer .NEVI/! Professional text Holds 100 I engine the supreme text including free editor only £49.95 Disks £6.99 cable £139.99 i All Prices INCLUDE V.A.T. VISA Orders over £25.00 Postage and Packing FREE! All other orders add £1.00 for Postage and Packing For prices outside 1111 please telephone I TransaThe Magazine for Amigactor Programmers Volume 1, Issue 4 The View Port 6 by Larry Phillips The good, the bad and the ugly side of the user interface. Publisher David H. Beatty (U.K.) The Future of Amiga Microcomputing 8 by David Wood Editors How will the Amiga fare in the future? Nostradamus couldn't tell — perhaps we can. Nick Sullivan Chris Zamara Mike Todd (U.K.) Amiga Modula — 2 Programming 12 by Clark Williams Making Modula — 2 Programs easy to , easy to type and easy to debug. Plus some general Assistant Editor programming hints. Malcolm O'Brien Turbo Tracing 20 Contributing Writers by Louis Markoya Steve Ahlstrom Producing ray-traced pictures is a slow business. Here is how the combination of a software package Scott Ballantyne and a 68020 board can make things much faster. Charles B. Blish Anthony Bryant Jim Butterfield The Changing of the Fonts 23 Betty Clay by Betty Clay Don Curtis Making better use of fonts — and how to ensure programs are compatible with the changes that Matt Dillon will be introduced with versions 1.3 and 1.4. Andy Finkel Brad Fowles Chad Innes Some Examples of Shell Programming 26 Eric Giguere by John Faichney Cathryn Graham Version l.3 includes a Shell environment which is capable of much more than the old CLO. What Chris Gray sort of tricks are there with the new Shell, and how can we get the most out of the new script files, Charlie Heath pipes and the startup-sequence? Perry Kivolowitz Rico Mariani Louis Markoya Bryce Nesbitt Rob Peck Larry Phillips Bob Rakosky Dan Schein John Toebes Victor A. Wagner David Wood Please Note: 7tansAml's UK phone number Is: REVIEW: WordPerfect's New Amiga Workbench 38 094939390

by Jay A. Gross CompuServe Accounts WordPerfect's library of utilities is aimed at making life easier. How does is shape up to the job? Contact us anytime on GO CBMPRG, GO CBMCOM, Calling the CLI from AmigaBASIC - Part 1 43 or EasyPlex at: by Jim Butterfield Karl J.H. Hildon 76703,4242 Chris Zamara 76703,4245 Although AmigaBASIC is fast and powerful, there are times when access to the CLI is a more natural Nick Sullivan 76703,4353 way of doing something. Our Gura looks at how we get at the CLI from AmigaBASIC.

t° lot the himcthly byTMtacMPuUMag Inc. 85-10 WW Wimd Street. Richmond Ha, Ontario. L4B 1KT, ISSN* 0314158. M enR'ries Wan the UK, Europe Superbase Journal 49 aassendha *send m lama= UK Lid.. Unit 2. Langdale Grove, Bavaria, Nottinghamshire, Superheat is a powerful database, but its very power leaves traps for the unwary. In this, the first England, NG13 a9a of a series of hints and tips, Precision Software (and others) provide a guide to avoiding the problems. Transactor Publishing Inc. is in no way Connected with Commodore Business Machines Ltd a Commodore incorporated. Commodore end Cabman Product nares are registered trade marks al Carmodae Inc. "LUCAS" for the 52 Subscriptions: UK21S by Brad Fowles - Europe/Scandinavia Air Mai 225 Although there is a lot of public domain software available, there is little public domain hardware! Sand al subscriptions to: Trarsmlar UK Ltd. This article describes how to build a 68020/68881 platform board for the A1000. Unit2,LangdaleGrove,Bipham,Notlsgham- sh're. England, NG13 SSR, telephone 0949- 39390.Note: Burow' jUMS areh8rdS:ran to address ONLY. For best results, use the order cardat thecenlerof themes/nine. Programming in M2AMIGA 60 Ouwlhy Orden: Transactor UK Ltd. Unit 2. Langdale Grove, Bingham, Notts.. NG13 &Ste. by Anthony Bryant Telephonic 049-3 3m. Although C and Modula-2 are very different languages, it is possible to translate C source code for Edtaul contributions are always welcome. pry orginai. previazdy unpublished mateial wK be use with the M2AMIGA compiler. Here we find out how, using public domain C source code as =tittered Program bangs and arides. idud an example. ing OFFS submissions. al more Man a few Ins should be provided on mL Preferred format Amiga 392 diabetes with ASCII text New Mary scripts shard be lweivalen, double spaced, with special characters or formas dearly malud. PJMs dcul be glossy Week and white Creating Run-Time Libraries prink with good high contrast Ihetaaa MwI 70 be on white taper with black LK My by Steve Simpson M mater! coped becomes the property or Transactor Publishing Inc., except by Wec& ar- Run-time libraries are one of the keys to the Amiga's soft-architecture. This article shows how to s add your own functions to the system. raPu ement. Mc.m apoaucmrig ht yrmrewAMo Permission is in eiyetbnotalgicaga6wx to Transactor Publishing Inc. (Canadian address above) for awriter's guide, The opinions expressed in contributed articles are not necesarilt oseofTransactor Putiehi g Inc. Of Transactor UK Ltd Although accuracy 4 a major cbpdtve. Transactor Pudsretirg Inc. and Transactor UK Ltd. carol assume liability for eras In autos a programs. Programs lead to rnneacto, lot the Naga, at apswing on Transactor for the Mega disks. are ¢4yrghl by Transactor Publishing Inc. and may not be dud& cared dammed without permission. Production Attic Typesetting Ltd.

Printing UK Edition Printed in England by Warners (Midlands) PLC Bourne Lincolnshire r'

Transactor iw the AM/GA

From the Kernel

Phoney Commodore Disks The Missing Article

It has been discovered that counterfeit Commodore Observant readers will have noticed the article branded disks are being sold by a computer shop in titled "Ray Tracing with a 68020 System" on the the West End of London. Although from the outside front cover of the October edition. Unfortunately, of the boxes, these disks look quite convincing, the we had to drop the article at the last minute and disks themselves appear to be cheaply made and of as a result we missed the opportunity to take its poor quality. reference off the front cover. Well, it's here in this issue for you to read. There is no doubt that cheap disks can spell trouble; sometimes the disks will not format, other The Commodore Christmas Show times the data will become corrupted weeks or months later. To avoid such disaster, it is well The Commodore Christmas Show is being held at the worth paying the extra and buying tested and Novotel in Hammersmith on 18th, 19th and 20th branded quality disks. November. This show should give us some indication of Just how popular Commodore computers really RPS. one of Europe's leading media manufacturers are, both in the business and domestic world. and maker of the Commodore disks, are concerned that these disks are being linked with both them— The Summer show was well attended, but most of us selves and Commodore. RPS have a significant rep— visiting the show were rather disappointed at the utation in the world of magnetic media, both for limited range of new products for the Amiga. reliability and consistency of quality, and they are Probably the only major new product was the naturally concerned about the appearance of these Bernoulli disk drive, which gives 20Meg of disk disks. storage on a removable disk — what will we see at the Christmas show? A full report in the next RPS are confident that this is an isolated incident, edition of Transactor for the Amiga. although they are unsure of where these disks are coming from. Of course. Transactor will have a stand at the show. Apart from subscriptions and back issues of They point out that all genuine RPS disks have both the Amiga and 8—bit versions of the magazine, "manufactured by RPS" on the boxes of ten and the the full range of FISH disks will be available. There phoney disks have cheap sliding metal guards. will also be an opportunity to obtain the "defini— tive" FISH disk catalogue (Introduced at the summer Agent show), Transactor disks. Guardian v1.2 and several surprises. In the October edition of Transactor for the Amiga we carried Larry Phillips review of ARexx, the If you're at the show, pop along and see us — we Amiga version of the language. look forward to meeting you.

What we forgot to point out is that ARexx is Version 1.3 available in the UR from: There is a lot of excitement about the appearance George Thompson, of version 1.3 of the . This is the Freepost, version with the very much enhanced printer Dippen, drivers, a fast , extra and enhanced CLI Brodick, commands and lots more besides. In fact, a very Arran, Scotland RA27 8BR. much better environment than 1.2.

14 m l~ 9-1

E Transactor tonne AMIGA air

There are two aspects to the new release. First of As an aside, we are all looking forward to a new all there is the ROM (or disk for the version of Superbase Professional which is reported A1000). This has undergone several changes since to include the missing features of the first version. the very first release, and it is understood from With Superbase having already improved significantly Commodore that some machines are now being from the original version 1.01. it certainly looks as shipped with Kickstart 1.3 ROMs Installed. though we will be seeing a very powerful package.

The other side of 1.3 is the new Workbench disk As we go to press, we have no date for its release, with all the additional commands and features. This but it imminent (there's that word again!). has been continuing its testing and is currently in version Omega 9 (whatever that means!) and is still TRANSACTOR with developers for testing. In the October edition, you will have read of the The final release is now imminent, although no firm problems being experienced by the main Transactor date has been announced. I would certainly hope to team in Canada. Since that issue, there have been see some sort of definitive statement at the many changes on either side of the pond. Christmas show It's early days yet, so It is difficult to say exactly Superbase what these changes will mean, other than to say that they now guarantee the existence of Transactor In this Issue, you will find the start of what we for the foreseeable future. hope will be a regular feature. It is the Superbase Journal, a compilation of hints and tips for users Contributions and programmers alike. At Transactor, we are always pleased to receive Compiled principally from Precision Software's own your contributions. Don't worry if you are not a Journal, this should take some of the mystique out budding Shakespeare, we will do any work that is of programming Superbase. necessary — but it helps if your work is on disk.

~■ MR ■■■■ ®■~eMNICROM From only £ 495+VAT i ■ L t IUUI Turns Black and White into Full Colour Within Seconds '•••r' irriccurz ENCIDŒn v QUALITY A3 OR A4 COLOUR PRINT SIMULATION APPLICATIONS IN ALL AREAS OF GRAPHIC DESIGN andD.T.P * Matt Offset Litho

• Uses Photocopies or Laser * Corporate Prints Identity * Metallic Foil * Wide Range of Colours • Logos Blocking • On Any Material * Packaging • Any Size * Costs Pennies and P.O.S * Binding Option • Curriculum * Glossy Screen • Overhead Projections Vitaes • Transparent Adhesive Foil * Stationary Printing * Signs — * Lamination OBEAL FOR ONIIOUBE PREBB1Nnav ©ONS AND BUREAU ©3Gt 1 For Futher Details Contact: Burocare Graphic Design 211 Kenton Road, Harrow, Middx, HA3 OHD Phone: (01) 907 3636 Fax: (01) 907 0027 N lJ _ HITi 10 Transactor tor the AM/GA b The View Port

User interface sins and follies

by Larry Phillips I can remember my reaction to ABasiC back then, thankful that I had a language I could use right away, but disappointed Larry Phillips is an Amiga Hardware and software hacker in a number of 'features', such as the line-oriented editor. At from Vancouver, British Columbia, and a Sysop on Com- that time, rumours of a new BASIC abounded, and all Amiga puServe's AmigaForum. owners looked forward to its arrival, hoping against hope that maybe, just maybe, would produce a good product A friend of mine once said, "The reason I like the Amiga so for the first time in their history. much is that so many talented people like it too." I tend to agree with him, especially when I look at the number and When it arrived, I was again disappointed, and again it was the quality of programs available for the machine. This includes user interface that was the culprit. The language itself, though the Fred Fish and Amicus collections of public domain and buggy, provided a number of extensions to standard BASIC, shareware programs, as well as the many commercial offer- and reading the manual was enough to make me think that per- ings, and probably more that haven't been widely distributed haps BASIC on the Amiga might be usable. Unfortunately, it for one reason or another. isn't (though some would disagree), because of the hostile en- vironment one is forced to interact with. Slow windows, and While there are dogs among them, the public domain offerings AmigaBasic's insistence on redrawing them at the drop of a are, for the most part, of reasonable quality, with a good per- hat, the interpreter's annoying habit of pointing out syntax er- centage of true gems. Considering that the authors of these do rors in a program even when you are trying to do something not ask for any compensation, the level of software in this cat- completely unrelated in the command window, and the world's egory is more than adequate. Shareware, the next rung up the second most unfriendly editor, all combine to completely ladder, tends to be of the same or better quality, though there alienate me. When 1 saw AmigaBasic, I thought that perhaps are those programs whose authors, in asking for money, are ei- ABasiC wasn't so bad after all. I can stand to have AmigaBa- ther overly optimistic, or are blissfully unaware that their of- sic loaded up only for short periods of time, and tend to avoid ferings are either poorly done or offered as PD by someone doing so except when 1need to check out a program written in else. BASIC. If it had been better in the user interface department, at least I could have used it as a language for quick prototyp- It isn't really surprising that there are a lot of good programs ing or one-time programs. out there, since the Amiga is one of those machines that appeal to many different types of people, whether they be artists, pro- This state of affairs made me stop and think about user inter- grammers, musicians, or just plain 'techno-junkies'. I guess faces, and how they affect the user's perception of a program. what does surprise me is the number of commercial programs A bad program, or a buggy one, is of no use at all, and no that are just not up to snuff, complete with hostile or non- amount of effort spent on the user interface will do anything Amiga user interfaces, lack of features, non-cooperation with for it, but a mediocre program could be perceived as good. other tasks in the machine, or, worst of all, flagrant bugs de- simply by virtue of being friendly and easy to use. A program manding an upgrade that never seems to come. It seems some- that one would classify as 'great' probably already has a good how acceptable to have flaws in a program that costs nothing. user interface, and that is likely to be at least part of the reason or that you have a chance to try before you buy, but the same for its success. flaws in a commercial product am a lot harder to take. AmigaBasic is a perfect example of a mediocre program that The other day, I was perusing some old programs, dating back could have been made better by the application of a little to late 1985, and ran across a game program written in ABa- thought. The 'Syntax Error' message does not need a re- siC. ABasiC, for those who haven't used it, was the BASIC quester, with the resulting inconvenience to the user of having provided with the early . I loaded up ABasiC to run the to wait for it to render, and then to have to use the mouse to game, and spent some time playing with ABasiC itself. cancel it. To me, having to move my hand off the keyboard to

F ~

n Transactor so. the AMIGA a ❑i use the mouse is unacceptable. It would be a different matter for the programmer and prevent you from inadvertently trying had I been using the mouse already, but since I am generally to calculate your mortgage payments from an IFF picture file, programming when I see that requester, I have both hands on but that is almost irrelevant - the user is the one for whom the keyboard. things should be made easy, and most users will save files with a name that is easy for them to remember, with or without ex- There are things for which the mouse is appropriate, and tensions. If you are developing a program and feel that you things for which the mouse seems forced and unnatural, and want with extensions, please' have the courtesy to al- programmers should always bear in mind that the keyboard is low the option of turning off the 'mandatory' switch. for many purposes at least as good an input device as the moose. Where possible, give users a choice - they will appre- Menu etiquette ciate it. The AmigaBasic editor is the epitome of unfriendli- ness slow and unforgiving, requiring the patience of a saint Menus are often a weak point in programs. The COMMSEQ should you hold down a cursor key too long, and having only flag allows you to specify a Right-Amiga key sequence that a few redeeming virtues, such as auto-indent and auto- perforans the menu selection. It costs nothing in terms of code capitalization of reserved keywords. size or speed to implement this, but will be very much appreci- ated by a user who likes the keyboard shortcuts. Using stan- Liable some other machines that use a mouseftcon based in- dard names for menu items is another important factor. If I terface, the Amiga does not attempt to force software develop- have to stop and think about what a menu item really means en into having consistent user interfaces, but allows them the because it uses 'Archive' instead of 'Save', or 'Copy region as freedom to innovate and create. This has both good and bad Kill' instead of 'Cut', it reduces my efficiency, is a potential effects on the available programs. On the good side, we do cause of errors, and causes me to have less respect for the of- have beautiful and imaginative programs, and on the bad side, fending program. we have programs that are truly ugly or difficult to use. Gadgets am offered in a variety of styles - Boolean, String, Of coarse, the user interface does not sap at the screen, but in- and Proportional - and thought should be given to what type is cludes the entire environment, from best suited to the job at hand. A pro- the organization of the files required grammer should not be afraid to use for operation, to the setup required, On the good side, we do have more than one gadget for the same job, and to how the program behaves when possibly offering presets as well as you exit. beautiful and imaginative string gadgets. A proportional gadget programs, and on the bad side, should, whenever possible, be 'real Personally, I like programs that look time', showing the changes as it is for needed files in an 'assigned' dhec- we have programs that are truly moved. Charlie Heath's file requester tory,and preferably in a that ugly or difficult to use... offers a good example of this. If up is assigned by the Amiga on startup, and down avows are provided, they hle s:, I:, devs:, and so on. Many man- should repeat when appropriate. ufacturers seem to think that you will always boot from their floppy, and make some unwarranted The way a program exits is important. Does it come back to assumptions on that premise. They will look for a file in a di- where you started it, to the same environment? I once used a rectory with a special name, meaning that you either have to program that didn't bother to restore my current directory to boot hoar their disk, play games with the Assign command, or where it was when I started it. I didn't realize it at first, and even use a file zapper to change their program. How much only became aware of it when I ran it, and then tried to delete trouble is it to look first in the current directory then, if the file a file after it had exited. Luckily, there was no file of that is not found, look in a standard system directory? I can tell name in the place it left me, but there could have been, and you from experience that it adds one line of code to the source that was enough to make me think twice about whether I want- if it is written in C or Modula 2, and the benefits of doing it ed to leave the program on my machine. am obvious. It eliminates special setups and assigns, and thus relieves the burden on users, most of whom would rather just All programmers hoping to have their efforts sold, or at least type a program name or click on an icon to get started. It also appreciated, would do well to look at the programs that are allows a lot of flexibility in where you put the main program. I well liked by users, and the process should not stop there. Just like my terminal programs in the c: directory, while others like because a program is finally out the door and on the store them in a directory reserved for terminals. A little thought on shelves doesn't mean it's finished. Improvements, bug fixes, the part of the author will allow all users to set things up and and user support will help keep a program selling, and gener- run the way they want to. ate user loyalty to a product and company. Listen to users' complaints and wish lists, implementing those that are good While I am thinking about files, let me take the opportunity to ideas. In short, do the best you can for the user. You will be chastise those who insist upon files having mandatory exten- doing the best for the Amiga community and your own com- sions. I will grant that fries with extensions make things easier pany, and we will all profit from it.

4-1— -►I9- TImKCefafae the AMIGA

The Future of Amiga Microcomputing

The details Nostradamus never told you

by David Wood

David Wood is a PhD. student at Southern Methodist Univer- play area is about 12 inches by 12 inches. There is no border, sity working on his degree in Electrical Engineering. His area only picture. The calendar image on the screen is in full colour of specialization is image processing. David has been involved and there am no etas lines. The leaves and numbers show no with computers since his high school days on an HP 2000 jaggies, even for edges that are to horizontal or vertical. minicomputer; trisfust microcomputer was an Apple fl+. The resolution must be high.

It's time to pull out the old crystal balL,Unfortu mtely, mine is No keyboard w mouse is seen. Except for the monitor, the as cloudy and cracked as the next person's. As I pea deeply desk is empty. Under the surface of the desk, there are five into the ball, I see new and exciting hardware fm the Amiga at subtly-lit rectangles. The rectangles are different colours and the start of the neat mileamium, Is my crystal ball telling the they are labelled. The first says 'Spreadsheet', the second says Muth or is it leading me by dm hand off a cliff? I cannot telL 'Calendar of Events'. The second rectangle appears to be on Let me get some polish and a rag to see what the year 2000 the screen at the moment. The rest am labelled as other types will bring. of business software.

Recently, several people have said that the death of the person- The running calendar program sounds a tone as the clock turns al computer is neat At first this seems like a ridiculous state- to 6:00 p.m. The office starts to change. The screen starts to ment. Personal compares of all shapes and sizes am all fold back into the desk until the monitor surface is flush with around us. They are at work, in the home, in schools - almost the desk's surface. The window in back of the desk has also everywhere. However, the statement has an element of truth. changed. The window now appears to look down at least 30 The machines that are being sold today are much more power- storeys to a busy city street. ful than the models sold just five years ago. It was not long ago that the largest had an eight bit poces- The crystal ball fades out of the office and into a biological sor, 64K of memory and two drives. Standard ma- lab. The room is large and has equipment along all four walls. chines of today have a megabyte of memory, l6 m 32 bit pro- Off in the comer, there am cages with white mice staring back cessors, floating point co-processor support, and a hard disk as at me. Nothing seems really out of place in the lab except a well as floppy disk drives. Tbday's machines with their in- large fish tank in the middle of the mom. The tank is a cube, at creased power and memory are not merely personal computers least four feet on each side. Many varieties of exotic fish are but personal workstations. swimming around in it. Underneath one edge of the tank is an Amiga It appears to be owning but I canna tell what it is con- The faun is exciting for the Amiga. The great new features of trolling. There are no keyboards or monitors aromd (plenty of today will pale in comparison to what my crystal ball shows. mice, though). Through the ball, I am looking at an ordinary room. At first glance. it looks like an executive's office of today. It has a The crystal ball is starting to fade out again. There am many door, a window overlooking a meadow, a desk and filing cabi- questions left unanswered. What was the Amiga doing? How net; nothing extraordinary. On the desk is a microcomputer did the scientists interface with the Amiga? Too many ques- monitor, showing a calendar. A second glance tells another tions, but no answers.

The crystal ball refocuses on a typical home. From inside the What will today's personal workstations evolve into? Let's house, I can hear noises from the family in the background. As take a look around the executive's office. The desk has a per- the swirling mist dissipates, the crystal ball scans the room, I fectly flat, clear surface. Rising out of the surface is a monitor. can see the back of an enraptured little boy. He is playing a It looks nothing like the monitors of today. The front is flat game and from the sounds I can tell that it is Space Invaders. and appears to be made of the same material as the surface of Some games have enduring appeal and seem never to fade the desk. The monitor is only a few inches thick, and the dis-

.- 0 171

lflI Transactor lot the AMIGA 4❑ l

As I get closer, I see that them has been a change made to the The on-screen tet is a mixture ofjuicy details and marketing game. Now it is in three dimensions: the barns and the de- hype. Skipping the latter,f learn many Mteresting details about scending space creatures have real depth. All of the action is the future... taking }dace in a glass-like cube, about eight inches on a side. The tads, or holotank is filled with a not-quite-clear substance "Scalability", I read, "is a word often abused by many com- that is good enough for home use. Close up, the space crea- puter manufacauras. It has become so overused that it almost tures show the effects of limited resolution. The game still has has no meaning any more, like the phrase `user-friendly' from the same colours as the (now ancient) 2-D version. the '80s. In the Amiga, scalability is not another buzz-word used to sell computers, but a reality. If two people need to use Ahab Something now becomes clear. The Amiga in the biology Me computer at once, all you need to do is to an extra lab was running a giant holotank. The tank was nota real fish window. No extra hardware to add and no switches to set. The tank M aq but a biological simulation. The Amiga must be Amiga is completely autoconfiguring. As you will see, scala- Bodkin some experiment. bility applies to just about all the peripherals that you can add to your computer system. Brimally the kid gets pounded by the space creatures. He leaves, which lets me approach for a closer look. The label on "The Amiga comes standard with a dual channel 16 bit the bottom edge of the compute says "Amiga I, The One to voicedaignal digitizer - more than enough resolution for Own". Using the magic of the crystal ball, I circle all the way recording steno. The Amiga supports a sampling rate of up to around the machine. The whole machine is simply construct- I megahera pa channel. (Fa top quality audio reproduction, ed. That me no cables coming out the front The left and right the fastest sampling needed is about 44 IkIohe a pa channel.) side have almost perfectly camouflaged rectangular ports. In For your signal processing projects, you can handle signals up fae, there at only a few cables and these come out of the to 500 kilohertz per channel without digestion from Missing. back: One rather thick cable goes to Of course, the amount of memory you die holotank. Another is the power have determines the length of the am- and had mat wires leave the ma- ple that you can take. chine Both are thin wires, our leaving The crystal ball refocuses on a from die tight side and the oilier from typical home. As it scans the "Sone projects require more signal the left There am no other connec- handling capability. If you need four, tions an the machine No keyboard? room, I see the back of a little eight, or more signals sampled contin- No moose? boy. He is playing a game and uously, the Amiga can handle it. With scalability, you can add as many signal The kid has left the joystick sitting from the sounds I can tell that it processing modules as you need. nod to the holotank. Itis sitting on the is Space Invaders... table aicomected Yet he was using "Amiga provides four independent the joystick to control the game. More voice/signal output channels. Each chancel can be controlled either independently or in concert with others. An almost unlimited number of output channels The crystal ball takes the liberty of searching through the desk can be added to the Amiga, depending on your amount of drawers. In the top drawer is an assortment of items: a track- memory and processor power. (More on this later.) ball, joydisk and touch tablet None of these have any cables to attach themselves to the Amiga. In the bottom drawer are a "As is well known, moving your software from one place to keyboad and a mouse, again with no cables. I cause the crys- another used to be a real problem. Software and data used to tal ball to bounce off the keyboard's Help key - not au elegant be stored in a layer of magnetic particles on thin plastic disks way to use the keyboard, but it does work. The picture on the that rotated in devices called disk drives. Unfortunately, the wall behind the Amiga changes: Mona Lisa disappears and an disks were fragile - one day in the summa sun and they would Amiga meta takes its place. droop. If placed too near a motor or other source of magnetic fields they could lose all their information. They watt easily The mans reads, "Welcome to Your New Amiga Please select damaged by bending (especially the big 5.25 and 8 inch die ase that you are interested in and click the left mouse but- disks). ton once. If the mouse is missing, press the corresponding function key." The first entry is an introduction to the hard- "These disks, or `floppies', are now historical items. The wale options available for all Amigas. I bounce the crystal ball Amiga uses the universally standard software cartridge, which off SOLO key I. is rectangular in form and about 1 inch by 1 inch by half an in- ch thick It is not affected by the environmental conditions that "Welcome to your new machine", the Amiga responds in an would tum a floppy disk into a plastic potato chip. One end of almost human voice. "It has many wondafnl capabilities that the cartridge has the contact plates and the other has a are awaiting your command. The Amiga is the first truly scal- coloured dot. Do not buy any software if the coloured dot is able personal workstation." red u Transactor to, the AMIGA a a "lb install your program, insert the cartridge in either the left "The Amiga supports both standard household networks. or right hand slots in the Amiga case. Once securely inserted, The first of these is the broadcast network, which works on a the dot should be green. Press the green dot. Even the largest very low frequency (vis) to communicate with your slow- programs only take a second or two to load. After loading, the speed peripherals. The keyboards, joysticks, mice, are among green dot will change to red. The software is now loaded and the peripherals that talk to the Amiga by this VIP network. The configured to your system. If for sane reason, the software single conductor wire that leaves the back of the Amiga, cir- should get damaged or erased from the Amiga, simply reinsert cles the room and returns to the right side is the antenna Since the cartridge and press the red dot. Note: the cartridge canna the transmitted frequency is so low, there will not be any inter- be used to load any other system while the dot is red. ference with the neighbors or even the rest of the house. Only the peripherals that are in the antenna loop will be able to talk "lb aninslall and remove any piece of software, insert the cor- to die Amiga rect cartridge and press the red dot. The software will be re- moved from the machine and copies you have made will no "The second network is the one placed on the house electrical longer run. The cartridge and its coitents can now be moved lines. This network is not broadcast over the open air so there to a new machine. is no chance of interference with the radio or television. It is convenient since no cables have to be laid. This network con- "In the battle to thwart software pirates, the Amiga uses the forms to nos standards so that it can control all of your net- recommended National Bureau of Standards NIS) encryption work-compatible appliances. Be sum to check your coffee scheme. All of the central processors have unique two-part se- pots, crock pots, lamps, fans, and other appliances for network rial numbers. One part is public information: the other part is compatibility so your Amiga can command these. WARNING: known only to the processor. The soft- Remember to select and set a unique ware cartridge has its own serial num- network address for your house. You ber. It, also, has a public part and a pri- must do this for the Amiga and all of vale part lb transfer software from The Amiga now supports the 56 your network compatible appliances. the cartridge, the processor sends an kilobit data lines that come If you do not do this, you may find encrypted message using two keys. yourself controlling someone else's The processor's private part of the se- standard from the phone house, or even worse, they could be rial number is one key, and the public company. The 1.544 megabit controllngi yours. [1] part of the cartridge's serial number is the other. The cartridge acknowledges data lines are also supported. "The Amiga comes standard with the the processor by an encrypted respon- Ask your phone company... hi-resolution flat screen. The screen is se. The cartridge uses the processor's lightweight and parable. The image is public serial number and its private rock stable, without the interlace flick- number as keys. The beauty of this scheme is that both the er of yesteryear, and boasts more than 16 million colours dis- processor and the cartridge know positively the identity of the playable. The screen is also much more rugged than in earlier other. This locks out software theft by one machine trying to models. The front surface is strong. and resistant to scratching emulate another. Finding the private pan to any serial number and smudging - now you can pack up your Amiga and screen is a tremendously difficult problem. and take it with you with no fear of damage.

"The engineers of the Amiga realize that a lot of old software "The newest option to the personal workstation Amiga is the is still on magnetic and laser media As a option, high-density 3-D holotank. Cluttered graphs and charts are much easier to 12-megabyte floppy disk drives can be added to the Amiga. see hi 3-D. Games take on a greater realism. CAD has never CD WORMs (Compact Disk Write Once Read Many) and looked better!" WMRMs (Write Many Read Many) are also supported as add- ons. These options are maintained for the convenience of Reading between the lines, I gather that there is not much soft- backward compatibility. ware available to support the holotank. I suspect that there will be more as time goes on. According to the marketing hype, "Solid State Cards (SSCs), however, are the mass storage `What's more, the new holotank is surprising affordable'. We medium of choice for the Amiga These smart cards are about will see... the size of your credit cards but slightly thicker, and come hi many different memory capacities. The Amiga supports up to "Printer technology keeps getting better and better. The Amiga 6 SSCs of any capacity at once. The smart cards are inserted in comes standard with several serial and parallel ports. Many the slot on the front panel of the Amiga. They offer several ad- different printers can be connected to these parts. Many manu- vantages over older storage technologies: they keep thew con- factures make different kinds of dot-matrix, daisy wheel, jet- tents even when there is no power, can handle high and low ink, and laser printers. Choose the one that fits your needs, temperatures and are not affected by magnetic fields. They are from economically-priced low-resolution black and white dot- small enough to carry hi your pocket and strong enough to matrix models to the higher-priced high-resolution colour send through the mail in a business envelope. Omen. QI Transactor arma AMIGA *ICI

"Analog telephone modems (300 through 14400 baud) are no ations like addition and multiplication. h also computes some longer supported by the Amiga's Operating System. The of the more complicated functions like exponentiation, Amiga now supports the 56 kilobit data lines that come stan- trigonometric and logarithmic operations (transcendental func- dard from the phone company. The Amiga will also support tions). The original Amigas did not have a math co-processor. 1.544 megabit/second data lines as an option. (The 1.544 nabs All floating point operations were handled in software, which rate is AT&T's T1 carrier network. [2]) This is a special service made the early Amigas cheaper to manufacture, but slowed that must be contracted from the phone company. down math-intensive programs.

"As an option, Amiga will support one or more high speed "Depending on the application, extra processors and co- professional networks. The network module will support the processors can be added to increase the power of the machine older 10-megabit Ethernet standard as well as the newer fiber without sacrificing flexibility and compatibility. If the applica- optic network standards. If you are close to the neatest junc- tion needs more CPU resources, then another cru and Apu set tion box, you can connect directly. You can access computers can be added. If more floating point power is needed, then the in the office across town or camputem,across the country. math co-processor can be added to the cru and AfT set. For Screens updates are almost instantaneous, no matter where the more graphics horsepower, add more GDP& If more external originating computer is." fro lines am needed, then mom lops can be added. As many co-processors as needed can be added to solve the problem. "As you have seen, the Amiga is a remarkably adaptable and This is the essence of scalability. In all, the basic Amiga offers expandable computer. This is why we can state that the Amiga so much. As your needs grow, your Amiga grows as well. This is truly a scalable machine. Skeptical? Read on... prevents early obsolescence of your investment. Press any key to return the Mona Lisa". "The Amiga comes standard with one main processor (cru) and one attached Slowly the crystal ball fades out It has pmoessar (API). The cru runs the us- given as an interesting look into the er's programs. The APT (attached pro- As many co-processors as world of the future. Only time will tell cessing unit) handles all of the operat what will come to pass. ing system details like task switching, needed can be added to solve paging, memory allocation, disk ac- the problem. This is the essence Annotated Bibliography cess, network control and other jobs. of scalability. As your needs With two processor sets (two each of [1] You can control your household the ams and APus), the Amiga be- grow, your Amiga grows as appliances today using the BSR X-10 comes a true multitasking mul iproces- well... system. A control console sends sig- sor machine. For even more hose- nals over the electrical lines to - power, more sets can be added. ules that plug into the wall sockets. The wall modules control your lamps and appliances. The "Each Amiga comes standard with three co-processors work- lamp modules gives 0% to 100% brightness control as well as ing alongside the main CPU. The first co-processor handles the remote on and off. Automatic timers, remote control through imerfaces to the outside world. It handles the traffic that comes telephone lines, hand held remotes, as well as controllers driv- in ova the vie broadcast network as well as the data from the en by RS-232 are available. More information about BSR is power line network. It is responsible for driving all of the seri- available from Radio Shack or DAR Industries (8200 Remmet al and parallel ports (via the VLF network). The fastest devices Ave., Canoga Park, CA 91304). that this co-processor manages are the WORM and WMRM disks. This input-output processor (mi') offloads the relatively [2] In the AT&T telephone network, the T1 carrier is a 1.594 slow speed 1/o responsibilities from the central processor. megabits per second digital channel. The T1 was designed in the 1960s to operate over twisted wire pair cables and carry 24 "The second co-processor is a graphics handler and bit manip- voice channels. There are many books on telecommunications ulator. It is responsible for quickly moving blocks of data of varying difficulties. The source that I used was "Future De- around in memory. It can also do logic operations on the data velopments in Telecommunications, second edition" by James during transfer. The graphics and data processor (own) can Martin. The book is printed in Englewood Cliffs, New Jersey draw basic geometric shapes with one command from the cru. by Prentice-Hall, Inc. The book notes that "[the Bell Ti carri- It draws lines, does hardware fills, changes the colour palette, er] is likely to be a standard for decades to come" (page 63). does automatic page flipping, controls the sprites, displays the fonts, and does other graphical tasks. Acknowledgements

"The first two co-processors (lop and GDP) replace the opera- I would like to thank Bill Knight, Ed Corr and Dr. Samir Soli- tion of the tutee specialized chips - Paula, Agnus and Denise - man for their technical help. I would like to thank Betty Clay that gave the original Amigos their power. The third is the for the time and effort she put into proofreading and criticising math co-processor. It handles regular floating point math oper- this article. p D Transactor terms AMIGA a O Amiga Modula-2 Programming

Visual Acuity: good technique, great buzzword!

by Clark Williams

Clark has been programming for 19 years in everything from No doubt my standards will seem idiotic or wise depending on COBOL and RPG to 68000's; IBMs using 05360; everything whether you disagree or agree with my personal standards. DECish, and even PICK systems. At last count he spoke 123 However, standards are important - even critical - to a properly different computer languages (not counting dialects of Pascal, constructed presentation of programming technique. FORTRASH, etc.... but his first love ù flying. When not aloft, he writes Modula-2 programs. My standards are based on a concept called "visual acuity." If one of the purposes of structured programming is to produce This will be a collection of topics dealing with programming programs that are readable by both machines and humans, then the Amiga using Modula-2. We will discuss several Amiga- we must give some consideration to what "readable form" specific topics, as well as some general aspects of program- means in the presentation of programs to programmers. The ming: coding standards, design philosophy, Visual Acuity, etc. presentation of the language to the programmer should allow for quick recognition of the elements of the language. A fast Admittedly these discussions will be of a religious nature. glance should be all that is necessary to !orate a clause or a Many programmers feel very strongly about coding standards. statement, etc.

Most views on coding standards are strongly bonded in the Visual Acuity is a measure of the speed by which a person un- formative years for programmers; attending classes where familiar with the code but familiar with a language syntax can their teachers have strong and unwavering opinions that are find an element of that language and understand the context of begging to be passed on to the students/ These views are often that element. passed on without the instructor feeling any particular or com- pelling need to point out that these views were obtained by Many people have suggested to me that Visual Acuity is too this teacher from his/her favorite mentor while attending some subjective to measure reasonably. I disagree! Based on the em- ivy hall filled with fertilizer. pirical evidence of some informal experiments, I think that any language has a maximum and measurable Visual Acuity. I I will say now that the views you read here are my own and think that the presentation of the form which yields maximum are based on my experiences in industry and academia. I offer Visual Acuity of a language can be measured and demonstrat- them to you not to convince you that I'm right - or that you am ed I also think that some of the discussions regarding some wrong - but to enable you to follow my code examples and/or languages made in the past few years have been without con- procedure fragments with greater ease. sideration of "readability," i.e. Visual Acuity.

You should try the examples that am the essence of these arti- I also believe that languages can and should be compared cles. Even if you know Modula-2, you should do the examples (within the context of the task to be implemented). Visual and programatically play with them to help solidify your Acuity should be an important part of that comparison. knowledge of the Amiga. There are many items to consider when choosing visually Coding standards, when they exist at all, are one of the most acute presentations, some of these are: strongly held views of programmers. Every programmer seems to have his own set of standards. Each punctuation • Printer vs monitor presentations. mark of these personally held standards is defended with Her- culean effort Often this defense is expressed in a language 1) Ribbon condition, Inking, etc. filled with graphic metaphor whose colour and imagery would put even the Amiga to shame. • Language syntax and construction.

F 12 I~ ~ IN] Transactor Mee a t% 1)w-mEN-asE statements. tered in examples they will be clascified

2) White space. Rule #0: Identifiers should have the first letter of each word/abbreviartoahnnemonic capitalized and only the first let- 3) Comments, use and content. ter. As an example, our identifier from above would appear as:

• How any is it to use the elements of a language designed to BufferRequiredFotfaskSwitching increase the visual acuity of that language. This means that identifiers that include words like USA would 1) Identifier-names (e.g. Underscore usage, etc.). be written as:

What at the goals of increasing Visual Acuity? UsaReyboardSwitching.

• Toreduce debugging time. It is not as easy as reading clear English text, but it takes very little effort to get used to - by it! • To reduce learning time for new users of the language. Guideline p0: Semi-colons and their use is another hotly dis- • lb standardize presentations, thereby increasing communica- cussed item. I will use semicolons as I think Dr. Wirth intend- tions with and/or about the language, including its structures, ed them to be used in Modula-2. The semi-colon will be used such as programs, modules, routines, elements, packets, etc. as a statement separator, not a statement terminator. Therefore, you will not see a semi-colon before an END statement or be- If you have read any books on structured programming, you fore an UNTIL, etc. may have noticed that the words "judicious use of white space (empty lines) and comments are useful in making your code Guideline 01: Comments are an element of most languages readable." That is usually the last comment you ever read that seem to be almost an afterthought in the design of the lan- from the author assisting you in making your programs more guage. readable. Some languages are worse at commenting than others; howev- Let's start with a discussion about identifiers. Identifiers er, Pascal and Modula-2 happen to have comments that can be should be easy to read. Some languages use the underscore easily and usefully employed in code. character to break up an identifier. So that identifiers like: M a personal method of comment and semicolon use I will buffer required for task switching tend to group comments using semi-colons. If a comment be- longs to a particular statement you will be able to tell which would look like this: statement it belongs to by the use of the semi-colour it will be placed at the end of the comment on trailing comments and at bier required_for_task_switehing. the end of the statement on leading comments.

If you attempt to type in this identifier you may discover that Thus the comment in the following code fragment the underscore character is located in a very inconvenient place at the keyboard. You might also agree that with poor fragmentation := TRUE; ribbon conditions the underscore may disappear and the identi- fier may be confused with similar identifiers. (* Inform the calling routine of the error *)

That axe several conditions that presentation formats attempt- Error :e TRUE; ing high Visual Acuity must consider. However, this is not an article on Visual Acuity so we won't go into those conditions. is in reference to the "Error := TRUE" statement since it is be- Rather, I have chosen a format that solves several of the prob- tween the previous statement and the semi-colon. However, if lems presented by those conditions that are encountered in a we had written the code fragment as: typical pcogramimg environment. fragmentation :e TRUE Some of these standards are "rules." Some of these standards are "guidelines." Rules are intended to be followed as rigor- (* Inform the calling routine of the error *); ously as possible. They can be broken but the intent is not to do so. Guidelines are just that. They will help you when you Error :e TIDE; get stuck and don't have the time to be creative. Each standard is descnbed below as either a rale or a guideline. Not all of the the ";" associates the comment to the first statement in the standards are described in this article but as they are encorm- code fragment "Fragmentation := num." In Transactor n, ua AMIGA 4 bl Again, this is a personal use of semi-colons and comments. It es. The statements belonging to the THEN clause should obvi- is something that makes code eat for me (and others) to ously be associated with that clause. When the THEN is used as read. If you don't wish to use this as a convention, that is your the syntactic terminator of the boolean expression you some- decision to make; but you will need to know it for following times don't know on quick examination whether the w state- my code more closely. ment is all on one line or not.

Guideline #2: Tb identify a segment of code, use the comment 3) Ownership of the statements should be obvious. The IF at the beginning of the code segment and use spaces to in- owns the TEN and the ELSE clauses and the TEN and ELSE crease the segment's visual acuity. clauses own certain statements. The indentation shown in the second method leaves no question as to which statements be- As an example: long to which clauses and which clauses belong to which statements. This makes it easier to identify each segment of FOR Indes e 1 TO EndofamzmmtLiet DO code and thereby increases Visual Acuity. (* Look for all atop.. *) The TDI Modula Environment END (* Look for all stops. *); You now have an idea of how I organize my code. Let us look at some code "à l'Amiga." Specifically, let's look at getting The following REPEAT-OETIL loop will process the started using Tot's implementation of Modula-2. We will start stops entered in the commend line. All stop by looking at the environment available to you when you first are processed unless an error ie found during start up a program under Modula-2. the processing. See functional specification page 3-144. We will be using ml's V3.00b implementation of Modula-2. *) TD1's address is 10410 Madison Road, Dallas, Dr 75238, (214) 3404942. REPEAT (* looking for the stops *) This will not be a forum for praising, nm for bad-mouthing UNTIL (* No stops left or an error is debated TM. I know that several of you have gotten treatment from TDI which can be determined by *) that was less than business-hie. Specific, you get no Amiga ( Error) OR ( Allstop ); help at all. I understand your fnauation, but perhaps we can deal with that problem through these writings. Guideline #3: A one-time note on Modula-2. There are several kinds of Probably the biggest debate in the world of coding standards 'modules' in Modula-2. There are program modules, library concerns the EL-TIEN-ELSE statement. My primary goal is to modules and client modules. Aprogram module is easily iden- make the statement and its clauses easy to find, and to show tifiable. B always begins with the word MODULE. A client clearly which clauses am marina-4 with which statements. module calls a library module. A library module is called by a client module. There are two basic ways to do the IF-THEN-ELSE statement. The fast is: Obviously, this client-library module stuff depends on what point in the execution of the program we are currently examin- IF Tarr ing. You could have a program module 'A, which is a client to library module 'B', which is a client to library module 'C', etc. mas All library modules have two parts: The second method is: 1)The DEFINITION MODULE. IF meotees> TBEE (* comment *) 2) The IMPLEMENTATION MODULE. ILS! ( cement *) Rule N1: You should always define the interface to a module/ program/ packet/ library/ function/ whatever first! The imple- mentation of the module will be much easier when the defini- I prefer the second method for the following reasons: tion is fixed first!

1) This method is, by empirical evidence, more visually acute. This does not mean that you will never change the definition of the interface you design. You may well throw the interface 2) The statement is an IF statement with two associated claus- away and start all over again. However, you should first plan

H I )al 9-1 ~u TansaetOr for te AMIGA rï In[ what you want to have as inputs and outputs and then review, library environment however, it offers us an opportunity to review, review! Write down questions and write down the an- write a library module that will define our environment as the swers to those questions when you find them. These kinds of standard indicates it should be defined. things will guide you toward producing better interfaces, bet- ta modules and better code Why can't we just always open DOSBare? Well, we could. But not by the arbitrary statement The Amiga Developer's Manual (Bantam Books) describes an environment for languages that plan on using AmigaDos. Spe- DOSBase := OpenLibrary (DOSName,O) cifically it describes how both the C and assembler environ- ments have the and DOS libraries already opened for the The reason is that there is a module that sometimes opens the user of the language. Neither of these libraries need be opened Dos library an on its own. But this module does not bother to by the user. The expectation is clearly that all languages close the library since it can't really tell when the program is should open up these two libraries. done using the module. The module is Months Streams.

We'll start with the following program module to see whether So, to determine when to open DOS - and when not to - we the appropriate libraries are in fact open using TDI's Modula-2. would have to always include the statement

Purpose: To determine what libraries were opened on entry to IF DOSBase = SYSTEM.NULL THEN Tin's Modula-2 environment. DOSBase := Libraries.OpenLibrary(DOSName, O) The plan of attack is to check the base addresses of the li- END; braries we are interested in. The two library base addresses we want are FarRase and Maltase. The definition for ExecBase It turns out that there are a couple of modules where this kind is found in a module that is very important to Tin's Modula-2 of haphazard programming is done (see especially the MOD- called AMIGAX. We'll hear more later about that module. The ULE Terminal). So, what we will do instead is to build a mod- second address is found in a module called DOStibrary. The ule that will open the libraries that we designate beyond DOS program module should check the val- and Fier and will always open DOS if, ues in these addresses as its very first and ally if, it is not already open. control statement If they contain ze- roes then the libraries are not open. If These routines will, in essence, That means that if we ever use the Ter- they contain non zeroes then the li- keep house for the Amiga minal module that we will have to hmies are already opened for you. close DOS library before the call to Since writing to the screen could mt- libraries. Terminal, or later we close the DOS li- POAT a module that automagically brary twice. Remember that Amiga- opens the rrsi ibrary (but doesn't DOS keeps track of which library is close it for you later), we will not use screen I/O. Instead we open and how many times that library has been opened. will write a file on the disk called AnswerFdadat" that will contain two lines telling us the state of the library at the start These routines will, in essence, keep house for the Amiga li- of the program. braies. We will call the module that describes these routines AmigaHoasekeeping. This would not be necessary if we knew the state of the li- braries from the documentation. But TDI does not give us any Library Maintenance Routines specific information on the state of Modula-2 on the Amiga when we first start out We need some routines to handle die opening and closing of libraries when using Tors Modula-2 and AmigaDos. What The program module to accomplish our goal is shown in List- shall we do? First we will follow some of the rules and guide- ing I and is called CheckEnvironment. lines that were defined. One of the first was to plan what we were going to do. Let us get started then with the planning. When the program module is nm, a file called "Answer- Fde.dat" will be found on the disk hi DPo:. The file can be dis- What kind of functionality should we have in our routines? We played on the screen by using the"TYPE" command from a would like to be able to call a routine that would open the Ex- CU. The file's contents should look like: ec and Dos libraries if they weren't already opened. We would also like a routine that would open whatever libraries we spec- Exec was open. ify. Each of these mutines would of course have their logical Dos was NOT open. opposites: routines that will close the libraries.

Obviously, Dos is not opened automatically in the mi Since we will be manipulating libraries, let's create a type that Modula-2 environment. This is contrary to the standard Amiga will be representative of the libraries we will be handling. The-

—b ~ Transactor with. AMIGA 4~

se will be the libraries that we have available to be put on the Otherwise we will return a set indicating which libraries were shelf of our Workbench. While we are at it we will need a set open. If the set includes a library, then it was open; if not, it- to tell us what libraries we have/had open. was closed. Look at the Emotion called RememberOpenLi- braries in Listing 2 to see how this was implemented. TTaH The second procedure will open the libraries that we've re- Libraryshelf = ( Moe, Dislvont, Dos, Graphics, quested. We need to be able to specify which libraries should Intuit, Layers, Translate ); be opened and we will need to know if the libraries were opened successfully. We can specify the libraries to open DnTheahel! . MIT a Llbraryahell; through a variable passed as an actual parameter If all the li- braries are opened correctly we get a ratio back as the func- We don't include the mathlibrary in these because, in TDI's im- tion value. plementation of Modula-2, the matlibrary is not something that you have access to as a library. It is already available to The problem (as always) is handling an enor. If the libraries you. You don't open Math ibraryBase; the variable doesn't aren't opened correctly, we want to know which libraries exist. Instead you simply use the functions as you need than failed to open. We can do that by letting the actual parameter serve a dual purpose. On input, it specifies what libraries are If we had a full shelf of libraries, we 'ould have all the li- to be opened; on output, it will indicate the Marks that failed braries open. If we are doing very and non-Amiga- to open, if an ea occurred, or return the null set if there were specific things we probably just want Dos and Exec open. So... no errors, This design approach requires that the actual param- eter be a call-by-reference parameter. MUST The procedure-function to accomplish this is called OpenLi- lullshel! a DnTheehal! ( Haea..Translate ); braies and is listed in the module in Listing 2. Note that we have used the (ser) - (ser) and Isar) + (sur) constructions Hnrmolahel! astTeahal! { Dos }; in the procedure-functions so far. We could also use the 1NCl. ((SET),elment) constructs as well. However I like the predi- Note that we don't include Exec in the normal shelf. Recall cate calculus form of these equations better than the function that we found out earlier that the Exec library is always examples. I think they are more clear and more Visually opened for us before we start. So we only check for DOS in the Acute. You may interchange these constructs according to normal shelf. your preference as long as you keep some modicum of consis- tency in them use. Now we are ready to discuss a routine. This routine will re- member for us which libraries were opened when we began. The CloseLibraries procedure-function on inspection of the We want the routine to return to us a variable that will allow us requirements is the same as the Openfibraries procedure- to find out which libraries were "on our shelf" at the time we function. It requires the same inputs and outputs so the poce- called the routine. This routine then will be a "procedure" dure-hmction looks nearly the same. Emotion. The next procedure-function is the routine that needs to open (Momentary aside... I think this is one of the gross errors that up the Amiga libraries for us as we would normally use the li- Dr. Wirth made with Modula-2. There is a distinct difference braries. That is, it should always make sum that Dos is opened, between PROCEDURES, which do not ream values through and any other libraries that we specify in an actual parameter their identifiers, and FUNCTIONS which do. Procedures may not supplied to the procedure-function. The close routine will look be used in expressions. Functions may be used in expressions, almost the same; however, the value returned in the actual pa- etc. In Modula-2 there are Procedures and Procedure Func- rameter will be slightly different than that which we have de- tions. Procedure Functions are FUNCTIONS. I wish that Dr. scribed in the routines above. The parameter will not return to Wirth had indeed left the key word identifiers alone between us the libraries that failed to open, but will return the libraries Pascal and Modula-2. It makes the code much more visually that were opened correctly whether there was an error or not. acute. "Mas, that ain't what happened.") It is not usually good practice to use two different calling con- We can then describe the inputs and outputs of our function. ventions for similar routines; however, many times that Is We do not need any input from the calling program. We do what must be done. The problem arises when looking at the however need to be able to check the "base" addresses of the nature of routines and modules. Modules are a collection of libraries. This will require that the function be able to get to routines that are similar in what they work on or do, for exam- the values (i.e. mwoar these base addresses) of the base ad- ple a math module or graphics module. It is my preferred de- dresses of the libraries. We will return the set showing the sign guideline to use a logical mutine interface, radier than try open libraries. We will return the null set if none of the li- to be consistent iD all routines within a module. In my exam- braries were open (an era since Exec had better be open). ple, the interface to OpenLibrmies and AmigoOpeniouse are

1— 16 • ITrarISClCtork, uie AMIGA 4 a 1* quite different, but they still are in the same module because Set op a string to may 'Mc nu open.' they are logically grouped or Mee was NOT open.'

Our routine then is called AmigaOpenlfoure. The idea is to wigo ( stringarny, maaaar ); TY NOS tax2lteady0p®e0 open everything that is specified. The code that accomplishes ISM Coat ( etrlagtrny, 1Hleader, Straglaap ) this takes whatever the RememberOpenLibraries rets (li- sm: braries already opened), deletes these elements from the open Mary request, deletes exec (it should be already opened) and tacit ( Stringing, upmbader, Strinycay ):

then opens the rest. Our calling value is left undisturbed unless (t there was an error in opening a library. In this base the value mil m the carriage atom for esthetics. returned is the libraries that wen, opened and a FALSE value for Keep in kind that Length is a amt of characters hut that the may starts with index rem. the function. t)

The module initialization requires no code. Stringicp I Lngti 1 Stdnghrny 1 ] := Cenlyewam: Staingl¢g 17eogth (Stringing I ] = Maned; That is the module. The program module in Listing 2 shows how to use (call) the routines. (* Set up far Min cite. *) Chamfter . ren ( Stringing 1 0 1 ); Listing 1: CheckEnvvonmeat Error := Mite ( lnswziildadle, ChaMuffer, IMOII aerttvirment: 1MC ( Length 1 Stringla.P ) 1 1:

in MA®E new !ta, MIL; Set op a string to say 'DOS re cpm.' PIM W4dkary MOM =an, D086m: or ICI Naft cpm.'. 11M Malla MOPS Open, Clam, Pllmack, *1 WleOndle, lock, aioch, bcuatDdtk, bdela011., Wign I stringing, Da11aader ); Mite; PIM Lilndn MOM Qmhlbrcy, CS; D lOf OoeSlreadgOpmM NM maw MmJMDaaan: DO Croat I Stringing, OHKedex, Stdnglzray 1 p of MM Strings IWtlC 4efmm, Coned aogt0; m D *1; Croat ( Stragirrny, CMM OPraseadn, striatum 1: la octal for the MSI MSCII line feed. +1 TAMS a 12C; P Stick m the mintage [Hera for esthetics. (a octal for the MSI lien anlage return. *1 Seep in KM that Length a a count of characters 15e: an onsitna • hut that the may starts with index mm. Deader = 'Inc ca': imbdar = Ta w': a) lotlader ' 1M': _' ~. Stringing 1 length 1 Strin9lny 1 1 := tarragetatum; W Stringlaay 1 Length 1 Stringing ) 1 ' L1neKeed; bsaaallalar ='df0:baerIlle.dat': it Set up for Mica cite. *) L>M CheaSraRtr = POEM TO Cheany: MaMaffer := iM 1 Stringing l 0 Chclmy = MGM [0..79)MMilt ): Error := trite ( in.oarsilaadl., rM Chaaeo[fc, malmadJl¢eeed : 11002211; wm l angtb stringing ) 1 h Damroady0pmd :1008Y: Close ( lmwrPlaaotlle ) Stringing : Charing; (* of D q aaziaffe[ : r5ar1¢agPtr: ® fLedbvirameot. bawAla11mdle : P11Ymdle; Cres :OWffi:

Mgr 1* Check Mvloracnt m) Mali:Sy: coed := mesa. o Ia; Liatlng 2: AMIGA Housekeeping amilaid90pend := Man o Ra: mom moa aigemeeheepag;

D 107 Doallredy0peS In SYS>01 NM IOW SIM Dana := Cpealibrarp (DMCw, 0 ) In libraries 1WMf ticse1lbary, OPestibraag: mMMa11 MSMI Inane; Imtl DSsMmtLfbruy DFMf DleMmtma, DalPmtib; baMlaandl. := 4n ( beserallaese, Modelai 1: Patl DOadbrary DFM[ PWaa, Minh PaY sraphtcmLfaery D¢0C 0[aphaelaw, Maphtair; D bsmdildmdle o Iildradle (11ML ) MM aaitlm DEMI aaftlmlae, IotoltlmCae: ! (* fia m opined eonssally *) In ayemLWrary DHSS agae11w, ayenw;

lE Transactor M nw AM[OA Parr tnnriabrabrary DDDR Trmslatonna, Traaeldadme; mc : I Bague o ELL DDD 1* add exec lib to the out m rill atom t) Tal LararyCart := LibrazyCart I aaeaelf I Bac 1 ED l Lanryaalf = ( We, Dlstlmt, Dos, Gnphiea, Intuit, layas, muleta); Oalieaalf • at 0p LSbragSk f: Dleklmt : I Dist/Ease o DILL 78101 Cal 1* add dirt at lb to the cut re will ratan') L16raryCart := Libra:start i mlladbelf ( DIANA ) Bllaelf • OnT.Belf ( Bec, Distant, Dos, Graphics, Intuit, Dayan, Translate I; braltelf • maeael ( Don 1: Dm : a DODhee o DOLL DID (* add don lib to the cart re will return *) PmCDaR lassterOpeadbrarSes 11 : afBPblf; Librarpit :• Libnrycert i mmedhalf (Dm I PaCaDD OptalLbrules 1 PDA LSbnrfcart : mffiehhelf I: BODBa; ®I PmCD1Da CloneLlbnrlee 1 va 6lbrarybrt : OameGhelf I: 30018111: FWl®lD m1va0Xa9caee ( via idbrmycazt : mioethlf ) : BOOMED Graphics : IF GraibtuBse o ELL FDiCmWD Y1gaClamamm ( Vat idbrarycmt : maeael ) : BODD9; DIDI (' add 'optica lib to the cart re rill atom Al LlbrazyCatt LibnyCat i mmedhelf ( Ga hice 9D YtgaBmeskxpro9. DID I DILD®n® DDOI iMpaemuNepinp; Intuit : IF IntdtlmBata o DILL TBE MOE ML; CA add Iib to the cart re will ratan') MOPS C1ceeLfbrarg OpeoLlhrery; Librarycat Lrbrazycart i Oomeraelf ( Intuit 1 DDTa 9tadaae; DD I DPOR DSslmtBse, Dlelant9tae; DM DOaata, DC®ae; Layers : a layerdase o IDL IIPORS CcapbicsBae, aghtce9r; (+ add layer lib to the cart re rill return') MORT IotoitlmBne, lntuttlma9e; La[azytar< - Libm ait t Wheal! ( layers ) MORT IayesnBw, Dayeraime; ®I DFDI Srwlatadae, Danlatodme; Translate : IP Tranlatadase o ELL (* Global that can b fund b the Da Sala are opautd here (* add translator lib to the cart re rill return') for clarity. Lanutart :. LIMrlCart i aaeaal ( translate )

1* lia (' 1)0 amans') flee ®(* of USE e) Library:half = ( bec, DistPmt, Des, aD (+ of ont *); Graphics, Intuit, layers, Translate ); Taal tlbraeyCart OofWaelf = SIT a LWnryaelf; m Bnubadpeotararlm; Cans Bllaelf • maaaalf I tex, Distlmt, Doe, Graphics, PROCEEDS OpeeLIbrarles ( Fia ttbrarycart : mmeYlf) : B00131; Intuit, layas, hmelate 1; via Bo®laelf = Ontbaelf 1 Dra 1; LanryBmk : Libnryablf; t) BEM (* Opm Libraries +) (* Rd of tib Glahal SIBS found in Da .,dole. *1 I DYt ( Larazpfart = aDeaelf 11 ) >>~ PPOCDID PmubrOPen4lbruL• () : Oomeaelf; PED Id6raryBoot := Exec SO Translate DO Cla LlbreyBmt a v1R Bec : I Exec I L1barySet LfbogBok : LararyOhelf; ~ LlborlCart : mDdrl; Endue :• apoLlkary l•exec.laxerp•, 0 I; LDwryCart ï L1LraryCart - aIDeaslf I Bec I B6I (' Pmtabsr Opta Libraries 'I in I (* IDitialmtlon for the sun of elements. *) Dlstlmt : I DiakFmt le LaoryCazt DID LarazyGrk := miDeaalt ll; DSektontaata :• 4eiHbr+9 ( Obtlmtita, 0 1; L14uycart := Lan[yh[t l' - maeaelt l Naiad 1 Check each of the possible libraries on the obeli and see tat is m I then. a) Doe : I Des I LDaaryCazt m P1 WeuyBok a Bec TO Translate DO DOaaae = OpmLrLnry 1 DOama, 0 I; Cha LlbrpBook a Lfbuyfat := Larazyhrt - lethal/31f 1 Dus ) H (®l lo Transactor tame AMIGA ~ al ml 9M II Grapllomue O p6 Graphics : II nannies D LybaepCut MN C1ase113up ( p'aphtapn 1 IIa m; GnpMuae := OpmL@ruy I Geapbiesb, 0 1; Lfbrup0ut := Ltbruyeet L1kuyGtt := LlbcufCnt - mmeakelf ( Griptiu - ameaelf 1 Graphies 1 ml VD 1 Intuit : 17 Intuit D LihruyCart bait : II Intuit Il LtbneyCut ~ TM II pteltlmpea o 1W,4 lateltlmaue = Opmbibnry ( Intuitionism 0 1: f® ClasaLlharp ( Iotdtima.. ) LlbruyCart := LtrcaryCart M; - OeAaAdf 1 Mat 1 LihraqGrL := LfhnryCUL - mIDsaadE 1 Intuit 1 m l ml

Sams : II layera 11 Lfbrary0ut Layers : D layers 3 LihrrtyCart p® fm layenlue := Opeotlbnry ( ILyeOBoe, 0 ): II Lapelae O NLL Lfbraryfazt := LibraryCazt - tryEeOelf 1 lays ) 1m Clmetikuy ( Layueae ml IND; Llh[uyCart := LihnaspCut - mtncSelf 1 Laper. ) beside : II Translate II L16ruyfS[t m (e CIE L rmtlnoM on neat page r11 TEN SratlatoIDru := OpeeWbruy taaslatorHr, 01: Translate : D Trandate D Lih[upLaet Lfteuyart ' LWianyhet fID - mIDeAhelf 1 Translate 1 II Trmsyatar8rea O aLL ml oEl C1maLikuy I Trauyatm0w DID; ma it 00 LOaDg el Llbraseut := LlbragCut misof CIS s) - 0010aehelf ( Tranelate I Pofpa rl: m l m® Ntruynrt = aoIDaffielf II m(rofUs) na Ir DO l0®g •1 m r of Caa q m OpeLihorlu: m lrof hat rlt moa LikaryGrt = Oomeeelf 1) MUD= elaeeLibnrka ( YU Lihragbrt : mlhaSelf 1: MGM; m lrofII9 m ClowdbnrLe: n Ll6er>Bmk : Idhnryi0elf: PI9CmDiR WOaOgolmse ( ga LiWaeyL9rt : Cnthessaif ) : 3101111:

MIN Ir Close Libraries rl D VDT ( Lthraytut = a>bapelf () ) In oonal kslga bane keeping the um library it already opened. el 1m Ya Lhmyloot := po N Malate OD TM Cka LWeglmk D LibrulesOpaed : 0othe8hdf;

pec : II pm D Libegart Elm (*kip two lone q TM Ir Ica a epee the lihrarlee re as. a) II 3aC8Ya o ILL LtbragCart := Full/belt Cloeydbruy ( Man 1 - Libegeut (` ma e ant. t) END; - Prrhmpotdbrulo () Ir ow already epa t) L4hrayCirt := 416ruyCut - Oradielf 1 Mc 1 - Orafoepelf ( po ) Ir me airaye apo. g , ml Ir hlmlate the llbnriee that re opened. e) Olaamt : II OLSmt D Ll6ngCart 18a LibnrinOpewd := Pallaelf - LibnrpCut: II OLHmteau o IAfL TIM C1oeeLlheup ( 01sVmtlus 1 111 1111 Opatdbnriee ( Llbrarlea0paed ) MO; LWreryCak := LibnryCut m a1pOp.mme: - apheaelf I O1sIPmL ) ml PPOCmm huigaClneelme I Pa LlbngCart : atae0telf 1: Mai;

Dm : II Dm D Lt0[uyCart Cr fal a anal alga hase keeping the nee lib !s cloud atomically. e) D Mass o l0L4 t>m CyoaeLibran ( base ) MIN (r bige Clou loose e) m; anW CImet rades (Lihraryart ) Li6reqhrt :a 416tu)Caet - ithasaslf 1 Om 1 MO iipClewme; ml alga pekaplog 9 O Graphics : If Cephie D LWnryCet m rigumsdoping. t ISl jo Transactor fort* AMICA 4 ol

Turbo Tracing

The real value in 68020 boards

by Louis Markoya

Louis Markoya is the creator of many well-known pieces of tracing software, for these calculations would be 1000 times Amiga art, including "The Watching Angel", on the cover of more without such optimization, and a ray-traced picture on TransAmi Volume I Issue 2. Louis also wrote the review of the Amiga could take as much as a year to render. Luckily, the Photon Paint that appeared in that issue. He can he contacted software manufacturers of Amiga ray tracing software have on Compuserve at 75766,504. overcome the time problem by employing different optimiza- tion techniques. Most Amiga owners' pulses go up just slightly with the men- tion of 68020 boards and math co-processors. The dream of a Using ray tracing in much of my artwork, I have often wished faster, more powerful computer is in our blood. I know of at for things to go faster, and I am always looking for the most least three manufacturers of such boards, varying in price and powerful software. In addition, I have asked myself just how features, but all relatively expensive. With this in mind, the much it would help to get a 68020/68881 board. These ques- practical aspects of owning such a board should be addressed. tions would quickly be followed by more questions concerned lust how fast will my computer be after installing this thou- with software and hardware compatibility. This article ad- sand dollar investment? (prices vary for manufacturers and dresses these questions, most importantly that of speed... how speed of processors) What do Sieves, Dhrystones and Savage much faster do things get? benchmarks mean to the end user? As a forum Iused Turbo Silver, from Impulse. Though the fin- Sure it all means your program may run faster, but exactly ished product is not on the shelves, the interim versions are how much depends on many factors. Most 020's available for available as upgrades to any registered user, and Impulse has the Amiga run at a clock speed twice the speed of the standard made a version specifically optimized for the 020/881 combi- 68000. This doesn't mean that everything will be twice as fast; nation. As my tracers go, Turbo Silver is one of the most com- graphics rendering done by the custom chips, for example, prehensive packages available, offering many advanced fea- runs at the same rate. Some screen functions can be faster, tures found only in professional packages (a full review will however, (especially drawing functions that requires math) by follow in an upcoming issue). Some of these features will be virtue of the math being done faster. discussed briefly so you can better realize the tasks set for the computer in rendering the images I have created for this test. There is little question that ray tracing is as computationally intensive a task as can be found for the Amiga. Using 4096 As for the 020/881 board, I've been testing the new Hurricane colours and the computing 2000 model, by Ronin Re- Turbo allIver Trace Tine horsepower of the 68000, the search and Development Inc./ Amiga is the first stock home tl • T-, • Finally Technologies. The T IMIABI we bras computer that makes realistic • 68020 is clocked at 14.32 ■ ,.ver •. ve traced images possible. On en MHz and the 68881 is average, some four million clocked at 16 MHz. By using calculations are made for a H a separate crystal, any speed simple low resolution picture 68881 could be used, and and easily 40 million when y { with faster math co- the objects get complex, or ~ processors even greater speed when glass and mirrors are • %// benefits could be realized. used. And these numbers de- TubesT.s vr.wwri ss id liver tom Although the board was one pend on the optimization Pi°u^ of the first shipped, its design techniques used by the ray was complete and solid; no

FJ 1201 44' Ju hanactor wrm. AMIGA o~ jumpers and no complications. It installed easily and worked ter, due to the higher math precision. This will be of greater flawlessly with both the 2090 Hard Disk controller and the benefit (and easier to visualize) with the introduction of 24-bit 2052 Ram expansion units I own. According to Ronin, the frame buffers, which Silver's already supports. In Hurricane board uses proprietary fast synchronization to both the floating point and integer versions, all scene parame- offer a performance increase over competitors. In simpler ters were kept the same. Light positions, objects, reflectivity, terms, they have found ways to address the Amiga 16-bit bus etc., were identical. Several techniques were discovered that in less cycles than competitor's boards. are contributing factors to trace times and are applicable to all ray tracers. In particular, the placement of lighting can make The premise for the experiment was to set up several scenes of vast differences in trace times (up to 300 percent!), and in varying complexity to trace. Knowing integer Turbo Silver al- many cases with little change in the resulting image. Follow- ready had substantial speed advantages over its competitors, I ing are descriptions of the scenes and images, plus the results was eager to see what differences floating point would bring. of the Standard Amiga vs. Hurricane 020 Trace times (In (Turbo Silver's speed can be attributed to the coding experts at Hours : Minutes : Seconds). Impulse and using Octree volume methods, which test space for and collision of a light ray with an object before the calcu- Note that "The Dragonflake" and the Silver logo are inter- lations are done.) It is also important to note that the actual laced HAM pictures, while the others are non-interlaced. This quality of traces with the Boating Point version is slightly bet- plays a major role in trace times.

4— 1211 ~ Transactor tor Ile AMIGA 0

The graph on the first page of this article depicts the amazing of Turbo Silver and the Hurricane/Ronin Reasearch board. For performance increase with the Hurricane board. With this level those of you who want to compute in the fast lane, this is the of speedup, one can drastically cut production times and per- way to go. fect the traces you dream up. Further speed increases of about 100% are expected with the addition of 32-bit RAM (to be test- ed and reported on later). For the professional and the enthusi- Turbo Silver ast, this may more than offset the pricing question. Impulse 6870 Shingle Creek Pkwy #112 As for compatibility, the Hurricane board worked flawlessly. Minneapolis, MN 55430 Virtually none of the software I tested (Word processors, Mu- (800) 328-0184 sic, Painting, Comm. etc.) had any problems (though I'll admit I never booted a single game during the review). And there wasn't the slightest hint of hardware incompatibility. I have to Hurricane 020 hoards admit, it has been great. Ronin Research and Development, Inc. P.O. Box 1093 In this article I have tried to demonstrate the real value of Alameda, CA 94501 owning a speedup board. I can highly recomend both versions (415) 769-9325

/041a'..

H rel If • CI Transactor teethe AMIGA 4 O

The Changing of the Fonts

Minding your p's and q's

by Betty Clay

Betty Clay, a former mathematics teacher, chose writing for PlanePick and PlaneOnOff and the remapping of the pens of her second career. She is the Amiga columnist on STARTErr (a the CharData for a greyscale font. When the ColorFont struc- videotext service of the Fort Worth Star-Telegram). She has a ture is fully implemented (as in 1.4), it will be supported in the regular column with tceua, and her work has also appeared in graphics.library. The Antigun. Betty can be reached via CompuServe's Amiga Forum. QuantumLink (bjc) or by mail at 1322 South Oak If you used fonts from an early version of Calligrapher, you Sweet, Arlington, Texas, 76010. may have found that some of them were unusable because of their memory requirements, and might be wary of using Color- Changes are coming! Versions 1.3 and 1.4 promise many Fonts. (The Amigan, Volume III, #2 gives extensive informa- changes to all pans of the Amiga. New features will bring a tion about this.) Newer versions of Calligrapher have this bug number of enhancements to the handling of fonts. Oh, the data removed, and a public domain program called FONTREP will still be held in bihnaps, and there will still be CharLoc (available on most bulletin boards) can repair whole directo- and CharSpace tables and the like. Current fonts will still ries of Calligrapher fonts with a single command. The problem work. Ramer extensive enhancements are coming, however, with those fonts was caused by a misalignment in the font- and pmgammers must consider these changes and write code name field of the program. Instead of having $0000001A in to make proper use of them. that field, the program was storing something more like $24052 (or even larger) there. This put the name in the What is different? wrong place; the Amiga could not find the name of the font when it needed it again, so it reloaded the font, and without One of the most important changes is that the user will no freeing the memory from the first load. The new disk- longer be restricted to using Topaz 8 or Topaz 9 for the default fonLlibrary (released with 1.3) will correct these fonts as it font. It is true that the public domain program SEFFONT al- loads them, ensuring that the colour fonts from all versions lowed us to install a different 8- or 9-point font instead of will behave properly. Topaz, but the size was pre-determined With the coming of the high-resolution monitors, this restriction would become These are the three major changes, then. The availability of most unpleasant, and it will not be imposed. many disks full of fonts, the introduction of high-resolution monitors, and the numerous programs that make use of colour Until now, the programmer could depend upon the default font fonts have made the changes necessary and desirable. How being of fixed-width. New releases of the software will permit will the changes affect you? the user to choose a proportional font for the default. Calculat- ing the space for a proportional font requires a different tech- Caution!!!! nique from that used when one may assume that a fixed-width font will be used. There are several things the programmer must do in order to make certain that programs will continue to work well and to Another change in 1.3 is the addition of ColorFonts. Support look good under the new circumstances. Here are the major for these fonts was developed in cooperation with Interactive considerations: Software, publisher of the Calligrapher program. The Color- Font structure will be fully supported in version 1.4, but 1.3 1. Programs mast gracefully handle large numbers of fonts. will support the use of multi-colour fonts with a fixed range of colours; setting the application colour map to that intended by Many programs currently in use are breaking because of this the designer of the font; and the remappmg of one colour of flaw. Probably the most notorious is the popular DPaint It al- the font to the RastPort APen. Features to be supported later ways gurus when given a long list of fonts, and this is a very include the remapping of the planes of the CharData with serious shortcoming. The use of a variety of fonts is important

H 1231 De Transactor er the AMIGA 4 o( in many DPaint applications, but the program is very limited in the text in requesters and alerts. Changing one of the fonts the number of fonts it can access at one time, and it offers no used by Intuitext can cause problems in any of these areas, and facility for reading a different Fonts: directory. this is especially likely if they are not all changed to the same font when a change is made. A particular instance is that the An even worse case is found in DeluxePrint. It allows only the screen and window title bar heights are determined by the use of the foots available on the original Workbench. How sad height of the font to be used in them. Making careless changes it is that two programs that are so useful would have been so to the height of that font as the program ruts will cause no- short-sighted on this particular point. They were, however, ticeable problems. among the earliest offerings. For a program- mer to duplicate these shortcomings now is inexcusable. Of all the things one should remember about Intuition and fonts, probably the most important is that Intuition will never 2. Programs must be able to handle various sizes of fonts. call for a font from disk If the desired font is not already load- ed into memory and available for use, Intuition will go to the When the programmer tests his program using the current de- default font. If a diskfont is desired then, it is necessary that fault fonts, it may look great. When his customer uses that the programmer open the diskfont before calling Intuition, program on a high resolution monitor such as the A2024, it leave it open until it is no longer needed, and then close it be- might be unreadable. The new software will allow the user to foreleaving. select his own default font Without care on the pan of the pro- grammer, the font the user selects may not fit into the space al- Calculations for text lotted for the necessary text. With care, the software can adjust to this flexibility without sacrificing any of the desired effects. Since users will soon be able to select fonts to suit their partic- ular preferences and requirements, and since the programmer 3. From the very beginning, Commodore-Amiga has stressed cannot possibly know what characteristics those fonts will that programers should follow the rules set down in the RKM. have, there must be ways to make the software adjust to any font that might be selected. When those conventions are followed, the new software releases will provide One way, of course, is to specify a par- all the protection necessary to ensure From the very beginning, ticular font to be used and to make that programs continue to work. Some certain that the specified font will be programmers like to fad neat ways to Commodore-Amiga has available to the program when it is get around the rules, and their pro- stressed that programmers needed. The user may not like the font grams will experience difficulty when that was chosen. On his screen, it may the system software changes. This ap- should follow the rules set be completely unreadable. Providing plies to fonts as well as to all other down in the RKM... and specifying a particular font does parts of the Amiga. allow the programmer to make certain that there is enough space for the Finding the information menus, gadgets, etc., to render their text.

Most text is rendered through Intuition, so it is good to know It is a far friendlier thing to let the user choose the font he where Intuition looks for the fonts it uses. Usually, the text to wants to use, and then ask the computer to tell you the charac- be rendered is part of an IntuiText structure, and it uses the teristics of that font. The height of his font will be stored in the font specified in the ITextFont TextAtn. Interext will use a TextFont and RastPort structures, and the programmer can just font from one of three places: access the proper field to get the font height. To get the width of a string, the IntuiTextLengthO function is said to be easier Screen->Font, to use, but since the TextLengthO function will report the Screen->RastPon.Font,or length of the string in pixels, this is a more accurate method of Screen->BarLayer->rp->Font determining string width.

When a screen is first opened, all three of these will refer to It is even possible to set up a special RastPort just for making the same font and that will be the one specified in the text calculations. Before opening a custom screen, the pro- NewScreen structure if it was available and openable; other- grammer can use InitRastPorto and SetFonto, and can then wise, the default font will be used. It is possible to change any safely calculate the title bar heights, widths, and layouts for all of these three fonts as the program runs, but if one of them is of the things on his screen. This method will work for a user- changed, all three should be changed. specified font, a programmer-specified font, or for the default font that is being used. (Information about the default font Inmitest renders most of the text we see on screen, such as: may be obtained by referring to GfxBase->DefaultFont.) From Gadget text, highlighted text and the text in string gadgets; Workbench screens, the information can be obtained from menu titles, items and subitems; window and screen titles; and GetScreenData.

H [241 1- Transactor tor taw) AMIGA r~ Other changes will follow these. New structures will be added Here, used with Stephen's permission, is the program: to the system software that will make it easier to calculate the /ttitttttt Ht *a**********t*IHfatint tlMtlltlll till space needed for text using unknown fonts. It is quite likely ran.g that we soon will have separate files for bold and italic fonts, and that there will be good ways to scale existing fonts auto- This program allows one to rename the directory matically with less distortion than we now find. Also, the which contains the font data files. Amiga is being sold in many nations. To ensure that a program copyright 1988 By Stephen Vemulen is usable in foreign countries, the fonts we use must be able to adapt to the languages of those nations, and must contain the ibis program may be freely redistributed so long as characters needed to write in those languages. the Copyright messages remain intact and the program is distributed with the supplied lamentation. Changes are already here, and even more changes follow. The Amiga just keeps getting better. syntax: rra thisfont.font path The font content files nitumwlnttttulut te tt lion tutNtutuwmly

See Traasacfor for the Amiga, Volume 1, Issue 1 if you are not include familiar with the font content header files, or the "font" files. star memame[256], oldvamel156]; They contain a file ID ($0x0F00), the number of entries for this particular family of fonts, 256 bytes to hold the path need- maio(argc, argv) ed to locate the actual font, and the height, style, and flags for int argc; the font Ifthere is more than one size or style in the family, all Char Ialge[]: 1 except the file ID will be repeated for each entry. These are FILE *font: very short files, and were designed to speed up the locating of long j, WC; the desired font. short 1, n;

It was not until recently that anyone really explored these files if (argc != 3) and made proper use of them. Stephen Venneulen (author of printf l'reo tilmase.font newpathW°I. Express Paint), recently posted to Usenet and other bulletin printf('cdjRlight 1988 By Stephen Vemenim\n'); boards a program he calls REN. It provides one of the most print! 1•3635 Rah err. N.N., Calgary, Alberta, CANADA, T2N 4A6 0); helpful font utilities yet to appear, and Bob Bums of Com- modore was quick to assure Stephen that it will not only con- else tinue to work under version 1.3, but that the utilities in that font = fcpen(aryvlp, release will not duplicate his achievement. Steve's work de- if (font) serves a very wide audience. /1****taa A* u*t I* t**5* ton n m tin euwu Using REN and some of the fonts I have accumulated, I re- now determine how many sites this font bas uw**nuen*uun*unm*un*uuweu/ cently prepared two disks of fonts containing only die actual font data, with the FontContentslleader files remaining in the fread!6n, 2, 1, font); /ta throw away **/ Fonts: directory of my boot disk. When all of the data files fread(in, 2, 1, font); /1t auger of sizes t*/ were removed to another disk, there was room for mom than pdntf(wont is baa Id sizes \n', argv(1], n): fifty font names in this directory, with many of those having for (1 = 0; 1 < n: 441) many mires The data for those fonts was stored on two disks, /** for each site m rename it... and each disk was divided into several directories. Pagesetter 40/ and Notepad had no difficulty locating any one of those fonts whenever I called for it. oPaint guru'ed. fseek(font, 41 1 260L a 1, 0); fread(oldome, 256, 1, font); So how did Steve do it? He simply used those 256 bytes for printf ("name was: is ', oldnm); for (j = 255; j > 0; —j) their avowed purpose. You tell his program where you intend if (oldvme(jl ='/') break; to sore the data for a font, and his program writes that path in- atrepf(oawnma, argv[21); to the FontContentsHeader file. It does this for each size and atreat(nemame, oldome t j): style at the same time. Then, when you call for a font, this path fseek(font, 41 ♦ 2601 a 1, 0); is read and if the Fonts disk needed is not available, the Amiga pride Moe Sa: ie\s', amnia); fwrttelnaraaae, 256, 1, font): will put up a standard requester saying "Please place Volume xxxnx in any drive." Since the proper disk is named by the felon (font); requester, I can confidently slip in the correct disk and every- thing works as smoothly as if the fonts were all still crowding my boot disk. What a wonderful tool! Thanks a million, Steve! f3

H 1z~1 Hf~ 1J • Q Transactor ter the AMIGA Some examples of shell programming

Scripts and choreography

by John Faichney

John Faichney is with The Arts Television Centre in Toronto. 2. Creating and displaying text files with Join and Echo In this series of articles, John will show how you can extend the functionality of the tools supplied with the Amiga's OS. As demonstrated in the previous section, by passing the 'cur- rent window' argument (an asterisk by itself) to Join as its 'in- This article features examples of shell programs - files consist- put file' parameter, we can create text files like Prompt.test di- ing of statements that, upon execution of the file, run normal reedy from the shell. Specifying the current window as Join's Amiganos commands. The point deserves emphasis: none of 'As' (destination file) parameter provides a substitute for the the programs featured in these articles contains any `object Type command: code,' though a few employ console control sequences. More- over, none contains any non-standard AmigaDos v1.3 com- LRAM DISK:> Join Prompt.test as* mands, even in those cases where their use would have made the programs easier to write. While Join does not require more than one argument to its in- put file parameter, we can also use Join to concatenate several Several examples address typical problems of file and disk instances of the current window: management, and may be of practical interest to users for whom address-space and/or file-system memory are scarce re- LRAM DISK:> Join* * * * * * * * * * as fee sources - those to whom the overhead of `object code' ap- proaches to file and disk management (DirUtil, DiskMan, and - though this is hardly the most user-friendly way to create a the like) is unattractive. Other examples, while fully function- 2550 (ten x 255 characters per CrRI. \) byte . Consider, al, will be of interest primarily as demonstrations of the pro- however, the following: gramming techniques involved. Yet others are nothing less than outstanding examples of shell programming. LRAM DISK:> Join * Prompt.test as S:StandOut

1. An outstanding example of shell programming and now enter:

Enter the following at the shell prompt An outstanding example of shell programming

LRAM DISK:> Join * as Prompt.test and type CTitt-\ Using Type this time to display the file:

Now enter the following: IRAM DISK:> Type S:StandOut number

Prompt "Esc[31m%n.%s>Esc[32m " we get:

(Note that the ESC key doesn't print to the screen.) Type the 1 ; An outstanding example of shell programming Crxtr\ key combination to send end-of-file to the Join com- 2 Prompt "%n.%s> " mand. Now enter. M these examples show, commands which normally direct I JAM DISK:> Execute Prompttest their IN streams from/to the file system can easily be made to orient to other types of devices. - the effect of which will be to render the shell window and prompt in Workbench colour 1, and command line I/o in "So what," you may say, "surely shell programming has more colour 2. going for it than a few tricks for creating simple text files."

~-I

It • Transactor o, the AMIGA 4dl

Ah, but a few tricks for creating simple script files will come Geffen features (line 2) a parameter declaration or 'template' in handy anytime we need to test some combination of condi- for the command line argument that is substituted into line 3 - tions parameters, etc., and don't need the features of a full ed- in this case, Join's As parameter. As with normal Amiganos itor. But while it doesn't really matter how scripts get written, commands, the "/a" suffix indicates that we want this script to perhaps a few observations on script presentation am in order. fail if it is executed without an argument Note also that the AS parameter occurrence in line 3 is embedded in double quotes, 1) All scripts will be presented with line numbers, and, where as the user may enter a bearing spaces or other spe-

appropriate, line breaks; these features are nor integral to the cial characters. scripts. Statement 3 also writes a prompt to the NewCon: window title 2) Both the semicolon command line delimiter - ';' - and the bar. Note that the use of space characters in this prompt forces dot-&-space directive - ' - will be used to distinguish in-code the enclosure of the entire window specification in double comments. quotes.

Note, however, that as of v1.2, at least, not all commands will We can now Run our script by entering tolerate the '; character as a command line delimiter (cf. Else and Endif; cf. also commands run as a single background pro- I RAM DISK:> Run Execute GetText foo cess and chained with the '+' character.) Funhermore, certain commands and directives (cf. dot-&-space) will not tolerate - and our shell window remains 'live' for other command line preceding and/or following tabs characters. These quirks are processing. simple enough that, even as bugs, they should not be a prob- lem; but any reader developing scripts under v12 who would Now, we can also create simple text files with Echo:

add comments and/or whitespace characters (other than the space character itself) to script command lines is urged to test I.RAM DISK:> Echo> foo "There's no foo like an for possible side effects, or, alterna- old foo." tively, to put them on separate lines. and we don't have to use the CIRC. \ 3) Commands may be indented with Echo's orientation to strings key combination to send end-of-file. However, Echo's orientation to strings the spaCe cater' imposesp some limits on the kind rather than files imposes some limits Finally: readers using word processors ofIfO it supports... on the kind of p0 it supports. Indeed, to develop scripts should check that it may seem as though Echo cannot file output does not, for example, strip express redirection of input; entering dot directives. LRAM Dtsie> Echo < foo? So: where were we? Oh yes - results in the response Passing the current window argument to an input stream pa- rameter has an undesirable side-effect the current window is : Invalid argument to Echo no longer available to us as a command line interface. Run-ing the statement (i.e., as a background process) won't work either The problem being that the string "Theis no foo like an old (nor, when you think about it, would we want it to). Run-ing foo" loses its double quotes inside the file. What's needed is will work, however, if we take the input stream from a console window: LRAM DISK:> Echo> bar "*"There's new ba like no old foo.*"" LRAM DISK:> Run Join NewCon:5/80/629/45/my_window as foo by which the asterisk'd double quotes are written into bar, maintaining the integrity of the string. But surely this is a cum- The reader may prefer to place/size the window differently. bersome way to create a text file. Indeed, one of the nice things about passing text to commands that orient to files for While this method works, its length makes it hardly more use- their input streams is the resilience of such commands to meta- ful than the statement it replaced. The solution, of course, is to characters like newlines and unclosed double-quotes - chaise- execute the statement from within a script ter sequences that Echo has a hard time understanding, but which are likely to occur (if for no other reason than typing er- 1 . GetText ror) when input comes from the keyboard. 2 .key As/a 3 Join "NewCon:5/80/629/45/Enter text (255 characters maxi- Note, by the way, that we can also use pipes as 'throwaway' mum); [Cntl.\) to close." as "" containers for text; far example:

H x7 19- 1 • Transactorlwm•AMJGA 4 of LRAM DISK:> Echo> Pipe:foo "Echo *"There's new foo like 1 . MoreText no old foo - nor, for that matter, like new bar - and ***"Hello, 2 key As/a world!***", while we're at it*" (12) 3 Join "NewCon:5/11/629/45/Enter text (255 characters maxi- mum); [CFRL-\] to close." "NewCon:5/45/629/45/Enter more Furthermore, we can execute such 'piped' scripts, just as we text (255 characters maximum); [ct'at.-\] to close." as "" would the 'fled' variety. Remember, however, that an Amiga Pipe: is a flip-flop kind of device: once 'filled', it can't be But it's hard to see much of a future in this. What we need is a filled again until it is 'emptied': once emptied, it can't be emp- script that accepts input, indefinitely, until the user says to tied again until it is filled. stop. The following script, rater, does just that.

But as long as we're digressing, let's have a few words on the 1 . Texter '7' argument. 2 key To/a,stor/s,tv.eo/k,FaE.t/k 3 .bra 2a. The l' argument 4 let ) 5 (SKIP) Experience tells us that the shell interprets command lines 6 Run > Nit Echo > Nil: < "Con:5/59/629/25/If no more text more or less according to the following routine: for (To), [return] in this window." 7+ 7 Echo> :thexter.d I) get the command line; 8 lab 2) fmd the file named by the first 9 Ifexists:Vtextecd string in the command line and 10 Join (DLE.o$Nil:) as "[TD)" check that it is executable; 11 Delete > Nil::Vtextex? 3) load the command from the Texter uses recursion to create 12 mse specified or implied directory an indefinite sequence of 13 Join [FILE.o) "NewCon: 4) if the 'T argument is present: 5/80/629/45/ Enter text (255 chame- -send the command's template to console windows into which tern maximum); [cTR1.]-\to close." as the output stream given with the text may be entered... (Fn.aI$:Vtexter.1) command (1f no output stream is 14 Execute Texter "Do)" skip file.0 specified, then the current window (Fa.E.t$:t/texter.1) file.! is the default); (tn.ao$:Vtexter.0) -append to the argument(s) given with the command the in- 15 Endlf put stream given with the command (if no input stream is specified, then the current window is the default), and sus- Texter's strategy is two-fold. First, Texter uses recursion to pend execution until the input stream closes; create an indefinite sequence of console windows into which - when the input stream has closed, execute the command. text may be entered; as each section of text is closed, it is added to the file of previous sections to make a new aggregate Many scripts featured in this series use the '?' argument to file, and a new window is opened. Second, Texter sets going force input redirection - sometimes from a window, other and then suspends execution of a background pnress which, times from the file system. Some exploit the suspension of ex- on re-activation by the user, finally terminates Texter's recur- ecution that '?' forces when the console is the input stream. sive loop. Some specifically exploit the fact that the suspended command (or script) is nonetheless loaded into address space before be- As you might expect, the background process is set up first, in ing suspended. A few combine input redirection with display lines 6 and 7. Assuming for the moment that the user has not of a 'descriptive' secondary prompt string. And one exploits yet replied to the backgound process's window (back to that in the redirection of the command template to the file system. a moment), foreground process control passes to line 13.

Various commentators have interpreted the integration of the Now, on Texter's initial execution, no argument is passed to 'T argument into Amigatws as a poorly implemented system FIE.E, such that it does not figure in line 13 - it simply drops of on-line help. Such an interpretation would seem to overlook out. Instead, the user is confronted with the (by now familiar) a substantial portion of its functionality. console window, the input to which must be terminated with CTRL\ In contrast, when (on initial execution) no argument is 2b. More on creating text files with Join and Echo passed to FLEA, it also drops out, but with the difference that the GetText is limited in that a maximum of 255 characters can be entered in one piece, without pressing RETURN. This is not :I/textecl bad, but let's overcome this limitation and demonstrate other programming techniques in the process. One way is to take in- is inserted in its place (note the default parameter flag, '$'), put from more than one window; something like: such that it is to this file that user input is written.

~ 1281 -Oh • fl Transactor for AMMIGA

Terser now manes (line 14), passing to itself whatever the You will remember that Statement 6 remains in suspense until user had given as a To parameter. Also patted are parameters the user makes Echo's window the active window and types generated by line 14 itself, including SKIP. Texter uses the oc- RETURN. (As no text is entered, no use is made of the en- curence of SKIP as a way of detecting whether or not it has hanced console handler.) Execution of the background process been executed from the command line or via recursion; i.e., as then resumes, creating (in line 7) the marker file. Control with- a way of ensuring that the background process runs only once, in the foreground process can now pass to line 10, where the no matter how many times Tester recurses. most recently updated of Terser's temporary files is copied to To, the user-specified destination file. Tester cleans up (line Returning to line 14: as this is still the initial execution of Ta- 11) and terminates. ter, the arguments accompanying the keywords FILEO and FILE.1 consist of the default parameters, Tarer represents a considerable increase in complexity over GefText, and some of that complexity resides in its details. For :t/texter.I example, three out of Tester's four parameters - "SKIP", "- :Vtexter.0 FILR.e", and "FILE I" - are for its own use. Note that SKIP is a 'switch': i.e., if "skip" appears as a command line argument, respectively, not until the next execution will the arguments then the keyword occurence "(SKIP)" in line 5 is 'filled in': if for FIES and PILE I figure in line 14. Note, however, the asso- not, then the keyword occurence - i.e., line 5 itself - is simply ciation of the keyword "file.0" and the argument left blank. (FIml$Pipe:texter.1) and the association of the keyword "file.!" and the argument (Fn.E.o$(Pipeaexter.0) - i.e., the as- Statements 3 and 4 define alternate bracket characters. As seen sociation of keywords and temporary files is reversed each above, the shell uses the characters 'c' and '>' to invoke in- time Tester recorses. It is precisely by virtue of this alternation put/output redirection. These are the same characters as those of keyword association that Taler is able to (in line 13) indefi- used to distinguish occurrences of keywords in script lines. nitely concatenate the user's input into one of the pipes. Without alternate bracket character defudtion, the shell will not tolerate input redirection (though it will tolerate output Sounds complicated? Let's try that again: redirection.) Statement 6 features input redirection; ergo, lines 3 and 4. Suppose that we call the first / third / fifth / etc. iterations of Texter the odd Many of the scripts featured in this ar- iterations, and the second/fourth/etc., ticle provide for redirection of console even. Now, on every odd iteration, line The kind of use made of output to the NIL: device; for example, 13 resolves to: temporary files is such that we Tearer line 6 provides for output redi- rection from both Run and Echo. In 13 Join :t/texter.l 'NewCon:...to might prefer to replace them these and other cases, console display close" as :Vtexter.0 with pipes... of secondary prompts or error mes- sages serves no useful purpose in the Get the current contents of a/tester.1, context of managing user interaction get some text from the window, and with the script as a whole. On the oth- put the concatenated result in .Vtexter.0. In like manner, even er hand, line 10's use of Na: is purely defensive; as the user iteration's of Terser resolve line 13 to could reply to line 6 fast enough to create :Vtexter.d before Tester had had a chance to recuse, a default input argument 13 Join :Vtexter.0 "NewCon:...to close" as :Vtexter.l must be provided to take the place of FILEO. and :I/tested is updated. While the assignment of default ar- If Texter may claim some elegance in its solution to the prob- guments to the FILED and FILE' parameters is fixed on Texter's lem of indefinite text concatenation, it's method of ending re- initial execution, thereafter the passage of arguments to FILE.o cursion is a kludge, no question. (As we shall see, we shall be and FILE.I is managed dynamically, in consequence of the al- able to say this about many of the scripts featured herein.) Fur- ternation of association that performed by line 14. thermore, we might prefer to find some way around the re- quirement that the user send end-of-file with each section of This process of alternately updating Tester's temporary files text; the CTRL \ key combination is both awkward and non- continues indefinitely - indeed, there is no way out of the loop intuitive. While the use of end-of-file ensures the non- within the process from which Texter was called. Instead, Tex- traumatic processing of control sequences and permits both in- ter checks (line 9) for the existence of a dummy file: tegral newlines and same-line text continuation across section boundaries, we might be willing to trade off some of that func- :t/texmcd tionality for the ease of use that accompanies closing off each section of text with a simple RETURN. Finally, the kind of use - that may be created by some other concurrent process - spe- made by Texter of temporary files is such that we might prefer cifically, the background process set going by Texter itself. to replace them with pipes. 11 • H Transactor mrm.AMIGA 4 Accordingly, Liner. 3 bra 4 let) 1 . Liner 5 FailAt21 2 .key To/a,sdre/s,Fn.s.o/k,tILK t/k 6 Execute > Nil: < "NewCom5/94/629/25/(PRoMF l" 3 .bur PutArgs "(TO)"? 4 .ket ) 7 If fail 5 FailAt21 8 Execute GetArgs "(To) "Entry not accepted. (PROMPT)" 6 (slur) 9 Endlf 7 Run > Nil: Echo > Pipeainm.d < "Con:5/69/629/25/If no more text for (TO), [return] in this window." 7+ But GetArgs is not the end of the line, either; GetArgs calls 8 Join Pipe:linerd as Nil: (line 6) yet another script, PutArgs. In fact, even though it is 9 Lab GetArgs which opens a window for input, everything entered 10 Join > Nil: Nil: as Pipe:linetd in the window is passed to PutArgs as an argument Whereas 11 If not fail previous scripts have featured input redirection to Amiganos 12 Join {FR.ao$:Nil:I as "(TD)" commands, GetArgs features redirection to a script Note also 13 Join Pipe:liner.d as Nil: how line 6 integrates the arguments passed to GetArgs: Liner's 14 Else "Pipe:hner.n" (Liner, line 15) is simply passed on to PutArgs 15 Execute GetArgs Pipe:linecn prompt "Enter text for as one of its arguments, while Liner's prompt string figures in (To) (15 strings 255 characters maximum.)" GerArgs' NewCon: tide bar. 16 Join {Fawn) Pipe:liner.n as (Fmn.t$Pipe:liner.1) 17 Execute Liner "(TO)" skip frle.0 (P11R.l$Pipe:liner.1) Why PutArgs should need to be executed in this admittedly fde.1 (FtLR.u$Pipe:liner.0) convoluted manner will become clearer as we turn to PutArgs 18 Endlf itself.

Liner is built on the same plan as Terrer, with a few small but 1 . PutArgs important differences. As the listing shows, temporary files are 2 key_0/a~1w2~3 4~5~6J~8~9~A~B~C~D E~F gone; instead, pipes serve both as text buffers and as markers 3 Echo > "<_0>" "< 1> < 2> < 3> < 4> < 5> < 6> < 7> for the background process. The former is pretty self- < 8>< 9>< A>< B>< 6< D>< E>< FS" explanatory; the latter introduces some new twists on shell programming. When GetArgs calls PutArgs, Liner's "Pipe:lnera" becomes the first of any arguments passed to PutArgs, i.e., it is associat- In line 7, Echo opens a pipe and remains in suspense until the ed with the parameter 0, PutArgs's destination file. PutArgs user ktrruRN's in Echo's window; thereupon (line 8), the pipe writes up to fifteen strings to _0; the others come from is emptied. As noted above, it is a property of pipes that, once GetArgs' window. (Why fifteen? Raa•e it seemed like a opened, no other process can fill the pipe until it has been good idea at the time. Note that if the user enters a string that emptied. Statement 10 therefore fails until the user responds, is identical to any of the keywords in PuzArgs' declaration, and Liner is able to detect (line 11) the state of the background then that sting will be assigned to that keyword, and the order process. of the strings will be cormpted. This is a problem for which there is no solution; all we can do is to use relatively obscure But there is another, more fundamental difference. Where Tex- keywords such as "_0", which am assumed to be unlikely to ter had taken 'new' user input to Join from a console window, occur.) Liner takes that input from the pipe: Now, nothing prevents us from executing PutArgs from the Pipe:linetn command line:

But from where does the pipe get its input? 1.RAMDIsg:> Execute PutArgs foo string_l string_2... suing_15 In line 13, Liner calls another script - GetArgs - to get user in- put (Note that Liner also supplies GetArgs with the name of though Echo, alone, will accomplish the much the same, as its pipe, and a prompt string.) Now, GetArgs is executed in the seen above. However, whereas Echo requires user-supply of same process as Liner - i.e., once Liner calls GetArgs, Liner enclosing double quotes, PutArgs pennies solicitation of user doesn't resume until GetArgs has terminated - clearly, GetArgs input as a series of separate strings. Furthermore, GetArgs pro- is where the action is. vides for recursion (GetArgs, lines 5, 7 & 8) should PutArgs fail due to faulty user input (meta-characters, too many strings, GetArgs consists of the following rather cryptic statements: etc.) In such cases, GetArgs attempts to assist the user by pass- ing to itself an explanatory prompt (GetArgs, line 8); on recur- 1 . GetArgs sion, this explanation is interpolated into the GetArgs' PROMPT 2 .key To/a,PRompT/k argument. H LaJ ~ Transactor torte AMIGA 4101 (Why was no FailAt statement included in Tesler, which also leads to performance degradation if each member of their solicits input via Echo? Because the `failure level' associated command-set must be loaded from floppy disk. If we Resident with the Echo command is not so high as to prevent execution their command-set at boot time, performance is acceptable. of subsequent statements. It may appear that faulty input to But we might not want to Resident the command-set every PutArgs brings down GetArgs as an indirect consequence of time; better that we save the original Startup-sequence as, say, the failure of PutArgs' Echo but it is GetArgs' own Execute "Startup-sequence.old" and make a new Startup-sequence in- which rejects the bad input, and prevents Echo from even corporating the calls to Resident. Then, if we want to go back knowing that any input had been received.) to our old Startup-sequence, we invent a name to call the cur- rent Startup-sequence (we will call it "DoResident- Returning now to Liner. Liner calls GetArgs (Liner, line 13), sequence"), and reverse the names: passing to it the name of the pipe to which input to GetArgs is to be directed (i.e., Pipe:hner.n), and a prompt suing. GetArgs LRAM DISK:> Rename S:Startup-sequence as simply passes the pipename to PutArgs as it sets up the New- S:DoResident-sequence Con: window from which the rest of PutArgs' input is to be re- 1.RAMDISK:> Rename S:Starmp-sequence.old as ceived (GetArgs, line 6.) PutArgs accepts the input, creates the S:Startup-sequence file, and terminates, returning control to GetArgs. As GetArgs has nothing more to do, control returns Liner, and the contents As a more general solution, we could dedicate a directory in :s of the newly-filled pipe are emptied into Liner's current PILE.o - let us name this directory "reqs" - to storing alternate pipe, (Pipe:liner.0 or Pipe:liner.l, depending on which recur- startup-sequences. We could keep a master of each script in sion called GetArgs. By this doubly-indirect strategy, Liner :s/seqs and (to change to a different startup sequence) copy manages line-at-a-time text entry; as all text is processed as from the master to :s/Startup-sequence. This keeps the non- suing input, end-of-file (CFRLy is not necessary. current sequences hidden from view, and less likely to be acci- dentally deleted or executed. 3. A digression on temporary-file management Unfortunately, with this arrangement our boot disk contains Tester and Liner depend heavily upon temporary files and two copies of the boot-file - a master copy, and the current pipes. In some cases, these resources working copy. Further, it is simply in- are used to 'emulate' flags and efficient to re-write the information; variables. Perhaps it seems as though we need a way to Rename the master this misses the point of what comput- A general problem with as the wur}dng copy without losing ing resources are good for, but let's track of its original name. We could find out what the tools can do, even if temporary files and pipes is put that name in a file, but managing by sometimes devious means. their vulnerability to corruption this many directories and files be- comes too confusing. What we need is A general problem with temporary in a multi programming a utility that both remembers the origi- files and pipes is their vulnerability to environment... nal filename and performs Startup- corruption in a multi-programming en- sequence subsitution. The following vironment Consider, for example, the script, ChangeSeq does exactly that. Execute command itself: clearly it would do no good were the temporary, parameter-substitution-resolved version of some 4a. Chartgeseq - a Startup-sequence management utility script to be clobbered by re-use of the same name as a result of, for example, concurrent execution of the same script. The Suppose that the current :s/Startup-sequence is the factory- same may be said of files/pipes used by scripts, regardless of supplied startup-sequence, and that there exists an alternate their purpose, and, in the end, the overall practicability of startup-sequence, scripts that orient to temporary files/pipes in a multi-tasking environment is founded on the possibility of assuring filename :s/seqs/DoResident-sequence uniqueness in some principled manner. Unless this goal can be realized, we will be forced to execute scripts one at a time, d la as we have already described. Suppose, also, that there exists a MS-DOS. Surely we can do better than that. file,

The next installment of this series of articles on shell program- :s/segs/current ming will be devoted entirely to the explication of a shell- program-based `solution' to this problem. the contents of which are none other than string:

4. Managing variation in startup conditions ":s/segs/Startup-sequence.old"

While text entry utilities like Tester and Liner can be put to That is, suppose that we have written the master pathname use in a variety of contexts, their exploitation of concurrency given to the factory-supplied startup-sequence to the file P•i Transactor fora» AMIGA rit :s/segs/current. (I have adopted the convention that scripts 4b. ChangeBoot- a boot-file management utility bearing the suffix "-sequence" are scripts written for the pur- pose of implementing startup conditions.) We could write all sorts of variation into ChangeBoot, but, for purposes of illustration, we will assume: first, that there exist In pseudo-code, ChangeSeq works as follows: the following files:

•check that Dokesident-sequence is present in the appro- :devs/coafs/current priate subdirectory (:s/segs); :s/segs/current •retrieve the pathname of the file currently being used as :s/starts/current :s/Starmp-sequence from :s/segs/current, and move the file back to the :s/seqs subdirectory (i.e., Rename it as and second, that each of these files contains the 'real' name of :s/segs/Startup-sequence.old); the boot-file currently in use; and third, that the directories •rename DoResident-sequence as :s/Startup-sequence; :devs/confs, :s/seqs and :s/starts contain non-current alternate •echo DoResident-sequence's master pathname to boot-files. :s/segs/current, so it may be retrieved the next time we nm ChangeSeq. A listing of ChangeBoot follows:

Translating all that into Amigaoos commands, we get 1 . ChangeBoot 2 key "FROM/a, devs/Systemxonfiguration=devs/confs/s, 1 . Changeseq s/Smnup=sequence=s/segs/s, s /Shell=startup=s/starts/s" 2 key FROM/a 3 .bra 3 .btu ( 4 let ) 4 key) 5 If exists :(devs/confs)(slsets)(s/starts)/(FROM) 5 If exists":s/segs/(RtOM)" 6 Rename > Nil: < :[devs/confs)(s/segs1(s/starts)/mutent 6 Rename > Nil: < :s/segs/cunent from : (devs/System) (s/Stanup) from s/Startup-sequence? (s/Shell)-(configuration) {sequence) 7 Rename ":s/segs/(RtoM)"as (startup) :s/Startup-sequence But it seems somehow wrong to 7 Rename: (devs/confs) [s/segs) 8 Echo >:s/segs/cutrent (s/starts)/(RtoM) as:(devs/System) " .s/segs/(FROM)*"" write several scripts when one (s/Stanup) (s/Shell)-[configuration) can get the job done... (sequence) (startup) ChangeSeq closely follows the model 8 Echo> :{devs/confs) (s/seqs) of its pseudo-code. In line 6, the inch- (s/starts)/current "*": (devs/confs) sion of the keyword FROM serves only to articulate how com- (s/segs) (s/starts)/[FROM)*"" mend line and redirected input are associated with Rename's 9 Else arguments; itis not, strictly speaking, necessary. 10 Echo ": (devs/confs) (s/seqs) [s/starts)/(FROM) not found" 11 Endif As made clear by the pseudo-code, line 8 stores the 'real' name of the current startup-sequence in :s/segs/current. Again, Changefoot takes two arguments, in any order. The first iden- the use of special characters to write quotation marks into the tifies which type of boot-file being managed. The second is file itself protects against the use of space characters in the the name of the alternate boot-file that is to be Renamed as filename. current. ChangeBoot looks for this file in whatever subdirecto- ry has been implicated by the first argument. If ChangeBoot Now, ChangeSeq is not so bad as far as it goes, but :s/Startup- can't find the file, it displays a message. Note that Change- sequence is not the only boot-time-relevant file that benefits Boot performs its operations in the current volume only. from this kind of management For example, there are times when I don't want to display the mouse pointer; yes, a pro- ChangeBoot looks complicated because the file/directory ref- gram could be written to change it to something else, but noth- erences of its command statements change according to which ing prevents us from writing a ChangeConf that does much the of the three boot-files is being managed. By declaring 'key- same work. word equivalents' (line 2), ChangeBoot accomodates variation in how arguments are actually used hi the context of individual The same could be said for any 'hardwired' file (:s/Shell- statements. (Restrictions on keyword length forces us to adopt startup, for example), or for 'softwired' files for which similar the devious tactic of representing filenames like file management techniques are appropriate (:devs/Mouotlist, "devs/System-configuration" as "devs/System"- for example). But it seems somehow wrong to write several "configuration "- though this particular scheme is only useful scripts to do the work that should be able to be done by one; for boot-files that include hyphens.) As ChangeBoot only accordingly, we are going to make some modifications to manages one boot file at a time, most of the bracketed parame- ChangeSeq. ters drop out, leaving behind only parameters relevant to the 4-( r1 F01- D • .fl Transactor wue AM/GA b current boot-file. For example, substituting the arguments giv- 5a. Assumptions and conventions en in Section 2a, we see that these statements resolve to: Executed in its default mode, this startup sequence makes cer- 5 If exists ":s/segs/DoResident-sequence" tain assumptions. These assumptions include: 6 Rename> Nil: < :s/segs/current from :s/Startup-sequence ? 7 Rename ":s/segs/DoResident-sequence" as :s/Startup- 1) that startup-relevant files are distributed across four disks, sequence the volume names of which are: Startup, Commands, Work- 8 Echo> :s/segs/cuuent "*":s/segs/DoResident-sequence*"" bench, and IFFfonts.

Identical to our first version. 2) that volume Startup includes the following directories: deys, I, libs, and s. New to ChangeBoot is the enclosure of all parameter declara- tions in double-quotation marks. The combined presence of 3) that volume Commands includes the directories. c, and s. equals signs (=') and multiple parameters requires the amal- gamation of the entire specification into a single string. As we 4) that the :5 directory on volume Startup and the :c directory shall see, this string may encompass a substantial amount of on volume Commands contain the commands necessary for non-keyword text, as well. the execution of their respective script files; and

ChangeBoot gives us a tool with which to manage variations 5) that the :s directories on volumes Startup and Commands in startup conditions; however, ChangeBoot requires that the contain the script files described below. system be running before any changes can be made. You may find that this is frequently inconvenient. What we need is a It is also assumed (though the script files described below do startup sequence (Does this come as a surprise!?) that allows not require it) that volume Workbench includes system- us to choose between default startup conditions and conditions relevant, icon-executable files such as :System/Format, :Utili- identified from the command line. R ties/Calculator, etc. Note, again, that would also help if we could run this these assumptions figure only in how , startup sequence in a 'defaults only' these scripts execute in their respec- mode; i.e., without having to sanction The Startup-sequence being tive default modes. That the user could each default parameter individually. described here is not a single be freed from being locked in to a par- The remainder of this ankle will be ticular set of startup conditions was a concerned with working out a shell script, but a linked series of major design goal in the development script with which to manage condi- eight scripts... of this sequence. At the same time, it tions implemented during the startup is no accident that the default execu- tion of this sequence has the particular consequences it does. 5. A multi-purpose startup sequence Beyond serving to demonstrate a set of programming tech- The following startup sequence makes relatively few assump- niques, the distribution of directories and files across disks im- tions about the physical configuration of the system and the plied by such reflects an interest in how system-relevant files manner in which system-relevant files are distributed across might be most effectively consolidated within a memory-poor drives or volumes. Furthermore, what assumptions it does Amiga configuration. Why consolidate system-relevant files in make may be altered as desired, during startup, by execution this particular manner? That discussion is beyond the scope of of the sequence in an 'interactive' mode. Finally, its design is this article; however, any reader who has had to interrogate modular, and therefore may easily be modified or expanded to half a dozen disks for the simple purpose of finding a common index different sorts of startup conditions as the consequences Amigaoos command will have some idea of the concerns at of its default-mode execution. This kind of flexibility will issue here. What is intended is that readers conceive a notion come in handy when your system requirements change. of how this sequence may be extended to comprehend the par- ticular startup options that are appropriate to their situation. It may be worth noting at the outset that the 'startup sequence' being described here is not a single script, but a linked series 5b. Principle of operation of scripts, beginning with :s/Startup-sequence on the boot disk, and ending (eight scripts later) with :s/System-sequence. Fur- We may think of the startup sequence as a compound script, thermore, the beginning and ending scripts are not even stored consisting of: on the same volume. As will become clearer, it is in virtue of this linked mode of construction that the startup sequence as a Startup: s/Startup-sequence Startup:s/Shell-sequence whole is able to bridge volumes without knowing the name of Stan up s/Default-sequence Startup:s/Workbench-sequence the volume to which it bridges, and to combine default and in- Stamrp:s/Commands-sequence Commands:s/Startup-sequence teractive execution modes. Commands:s/Fonts-sequence Commands:s/System-sequence

4-I ~N- p • 11 TrantaCtortwth•AMfGA We'll see that Startup:s/Shell-sequence executes Startups/ De- stantive' argument; i.e., an argument which, if supplied, alters fault-sequence so as to leave the input stream open, i.e.: the execution of the startup sequence in some substantive manner. As noted above, this could be (but is not limited to) Execute Startup:s/Default-sequence 7 assigning different logical directories, adding different num- bers of buffers, and mounting different devices. (How these As will become clear, Startup:s/Default-sequence is waiting possibilities are implemented as arguments and statements de- for one of two sorts of responses: pends, of course, on what startup conditions are to be real- ized) 1. the character 'd' or the string "default", plus RETURN 2. anything else (except special characters), plus RETURN Sc. Detailed analysis

Upon some user response, the input stream closes, and the re- The first script in the startup sequence consists, of course, of mainder of Startup:s/Default-sequence is executed, including a Startup:s/Startup-sequence. call to Startup:s/Workbench-sequence. It is the central feature 1 ; Startup:s/Startup-sequence of this startup sequence as a whole that in what mode Stan- 2 Run > Nil: SetAlert ; all typical v1.3 stuff that up:s/Workbench-sequence is executed - with or without the '7' argument - depends on the user's earlier response to Start- 3 FastMemFirst ; either should happen right up:s/Default-sequence's prompt. 4 BindDrivers ; away or might as well as it 5 AddBuffers Startup: 5 draws on directories included You say this sounds confusing? Let's try again: 6 FF>Nil:-0 ; on volume Startup. Note that 7 SetMap ural ; commands incl. on Startup: The last statement in Startup:s/Default-sequence consists of: 8 SetClock> Nil: load ; are retrieved from the root 9 Resident Cu L:ShellSeg sysmm pure; directory (not from :c) Execute Startup:s/Workbench-sequence 10 Resident Resident pure 11 Mount NewCon: Now, whether Startup:s/Workbench-sequence is executed with 12 NewShell NewCon:0t200/640/200/MyShel from Start-, the `?' argument depends on whether the user enters the char- up:s/Shell-sequence acter 'd' (or the string "default") in response to Start- 13 EndCLI > Nil: up:s/Default-sequence's prompt. If 'd' (or "default") is en- tered, then parameter substitution resolves Stanup:s/Default- In line 10, Resident is made resident; other commands will sequence's last statement as follows: follow, below. However, to exploit resident commands, we must activate the enhanced (v1.3) shell; i.e., once we have run Execute Startup:s/Workbench-sequence DEFAULT the commands that are (a) never run more than once, and (b) invariantly associated with startup, we want to get out of the - and Startup:s/Workbench-sequence is executed without the CLI and into the enhanced shell - even though Startup:s/Shell- '?"'argument; i.e., the input stream remains closed to the user. sequence cannot be executed (line 12) so as to leave the input If, on the other hand, no suitable suing was entered at the ini- stream open to the user. tial prompt, then the above statement, turns into: 1 ; Starmp:s/Shell-sequence Execute Starwp:s/Workbench-sequence ? 2 Resident Startup:Execute 3 Resident Stamtp:en - and Startup:s/Workbench-sequence seeks additional input 4 CD Ram: from the console. It is in consequence of this modification to 5 Execute Startup:s/Default-sequence ? Startup:s/Workbench-sequence's mode of execution that the user has the opportunity - at exactly this juncture - to perform Startup:s/Shell-sequence exploits command residence to exe- parametric substitution from the command line. cute what few remaining basic startup conditions are imple- mented prior to the execution of Startup:s/Default-sequence; It may be worth noting that Startup:s/Workbench-sequence i.e., prior to user interaction. One inevitable consequence of makes no use of the "default" string, other than to pass it to such is the creation, by Execute, of temporary files. The im- Stanup:s/Commands-sequence, which passes it to a subse- mediately compelling reason to relocate the process to RAM: quent script, and so forth. Its sole purpose (if entered) is to (line 4) is to avoid setting :t in volume Startup. `switch off' the argument and thereby, for subsequent scrip- ts, invoke default execution. So what about managing the con- 1 . Startup:s/Default-sequence sequences of the startup-sequence - the reason why we made it 2 .key "D=DEFAULT/a" interactive in the first place? 3 Execute Stmwp:s/Workbench-sequence

In addition to the "default" string input described above, each As has already been made clear, Startup:s/Default-sequence's script (subsequent to Startup:s/Default-sequence) takes a `sub- reason for being is to structure the user's choice between rtm-

N 34 1• Transactor mra.AMIGA 4in[ ning (subsequent) scripts in default or interactive mode. Hav- comma by which it is distinguished from DEFAULT. That's ing said that, it bears noting that we don't really need a sepa- right the keyword, or placeholder for all substantive modifica- rate script to give the user this choice; the presence of tions to the current script is undefined with respect to pattern- ]=DEFAULT as a parameter in each subsequent script in the matching; it's sole pattern-matching property consists of the startup sequence implies that choice with each prompt. On the two strings that it will not match: `d' and "default" Close ex- other hand, articulating this choice in a separate script also al- amination of the script will reveal that this `null' parameter oc- lows for the display of a specific descriptive prompt (see sec- curs five times in the body (lines 3-25) of the script tion 5d, below). Startup:s/Commands-sequence is stored on volume Startup. As I . Startup:s/Workbench-sequence suggested earlier on, it is a feature of the manner in which 2 key "IkDEFAULT/s,L=LOADWB/s" scripts are executed that they are brought into address space 3 ;As LoadWbs on boot disk, pathnarne not required before parameter substitution is resolved. An attractive conse- 4 Execute Startup:s/Commands-sequence quence of this is that having loaded Startup:s/Commands- sequence, volume Startup may be removed from the drive, and As described above, user entry of "default" as a command volume Commands (or whatever volume contains the directo- line argument to Staaup:s/Default-sequence causes "default" ry to which c: will be assigned) inserted. Constructing Start- to be passed through Startup:s/Workbench-sequence to its suc- up:s/Commands-sequence such that references to volume cessor. Executed as such, Startup:s/Workbench-sequence de- Commands (or other disk) do not need to be 'filled in' until nies the user the opportunity to choose to load die Workbench volume Commands is actually required yields a major payoff screen environment (at least until the startup sequence has fin- in avoiding redundant disk swaps. ished). Executed interactively, the user is given a choice: 1' or "LoadwB" to load the Workbench, RETURN to pass. For many The purpose of Startup:s/Commands is to make resident some memory-poor Amiga users, to load or not to load Workbench of the more commonly used commands, plus those that are is very much a question. As one who appreciates and recom- necessary for the efficient progress of the remainder of the mends the Workbench screen environment, I wish this was not startup sequence. As certain commands am brought into ad- the case but if the question is going to be asked at all, it saves dress space, a number of subsidiary startup conditions are real- disk swapping to ask it now, early in the game. ized; e.g., as of line 18, the effective search path for non- resident commands is: the current working directory (currently The next script is somewhat more complex: RAM:), then RAM:, then Commands:c, then C (currently Com- mands:c). 1 . Startup:s/Commands-sequence 2 key ",D=DEFAULT/s" The apparent redundancy of this path is misleading. As 3 "<$Commands:>c/AddBuffers" > Nil: "c$Commands:>" 5 Sys:System and Sys:Utiliües no longer reside on the same disk 4 Resident "<$Commands:>c/Assigti' pure as c:, it is a matter of some importance that RAM: and Com- 5 Assign C: "<$Commands:>c" mands:c be added to the path at this time. Note, incidentally, 6 Resident C:Echo pure that Path cannot be Run as a background process (which makes sense when you think about iL) your favourite commands Note that line 24 assumes that there exists an :s/Startup- 12 Resident C:MakeDir pure sequence on the root level of the volume to which e: is as- 13 MakeDir Ram:env signed. For what it's worth, such facilitiates the execution of a 14 ; Rama automatically created by Execute factory-supplied :s/Startup-sequence on, for example, an appli- Startup:s/Defauh-sequence cation-oriented disk (as long as such disk possesses Start- 15 Assign Env: Ram:env up:s/Commands-sequence's command set.) Supposing, how- 16 Assign T: Ramat ever, that c: is assigned to Commands:c, then the execution of 17 Resident C:Path pure Commands:s/Startup-sequence follows. 18 Path Ram: C: add 1 . Commands:s/Startup-sequence ; more of your favourite commands 2 key ",I1=DEFAULT/s' 3 FailAt21 24 Execute "c$Commands:>s/Snmup-sequence" 4 Assign S: "c$Conunands:>s" 25 Resident Path Remove ; 5 Path S: add 26 Resident Assign Remove ; not needed after startup condi- 6 Run > Nil: Execute DoDate ; I/D such that it's OK to run tions realized concurrently 7 Execute Fonts-sequence There are several things new about this script, though - for our purposes - the main interest is the introduction of a somewhat For the benefit of those users who lack a clock, Conunands:s/ unusual parameter a parameter declared only in virtue of the Startup-sequence introduces a subsidiary script DoDate ll• Transactor rwa.AMfGA a ❑[

(which is assumed to be able to be found in the directory to : enter d=DEFAULT for default startup sequence I return to modify which s: is assigned; though, if it isn't, the main script will continue anyway). As it is given that the volume on which Do- Date is stored will be mounted during Commands:s/Startup- sequence's execution, this is a good (i.e., fewer swaps) oppor- where the colons, the single character 'd', and the string "DE- tunity to execute a subsidiary script as well. FAULT" are rendered in colour 2. The functional portion of the declaration, being rendered in colour 0, does not appear. Again, assuming that the uses had assigned s: to volume Com- mands, Commands:s/Fonts-sequence follows: Second, Startup:s/Workbench-sequence: 1 . Commands:s/Fonts-sequence I . Startup:w'Workbench-sequence 2 .key ",i =DEFAULT/s" 2 .key "Ese[32m :Esc[31m enter ESc[1,32miesc[Om 3 Run > Nil: Assign Fonts: "<$IFFfonts:>fonts" =Esc[1;32m LoadWbEsc[Om to load Workbench 4 Execute System-sequence screen environment I Esc[4mretumESC[Om for CLI on- IyFSC,D=DEFAULT/s, L=IAADWB/S, ESC[32mFsc[E Fonts: is assigned in a background process (line 3) so as not to 3 QAADWE> hold back Commands:s/System-sequence. 4 Execute Startup:s/Commands-sequence

1 . Commands:s/System-sequence ;... etc. 2 .key ",D=DEFAULT/s" 3 FailAt21 where the prompt looks something like this: 4 Assign Sys: "<$Workbench:>' 5 Path Sys:System Sys:Utilities Sys: add : enter 1=1.oadWb to load Workbench screen environment I re- 6 ;Execute -sequence ;more scripts ? turn for CLI only

Re: line 3 - As it is possible that the volume to which the user assigns Sys: lacks one or more of the directories named in line Our last example of control sequence integration is Start- 5, FailAt is once again necessary. Note that, with line 5, the up:s/Commands-sequence. Path additions in this startup sequence are consistent in con- tent, if not order, with those of the `official' Amiga Workbench 1 . Stanup:s/Commands-sequence startup sequence. 2 .key "ESc,Esc[32m:Esc[31m enter Esc[3;32mrool:EEC[Om to assign C: to volume ESC[3mrootESC[Omc I 5d. Improving the descriptive power of secondary prompts ESC[4mretum Esc[Om for Esc[1;3mCommands :ESC[OmcESC, D=DEFAULT/s, ESC[32mEsc[E " All normal AmigaDos commands and scripts executed nor- 3 "c/AddBufers" > Nil: "c" 5 indicate to the user the kind of input being sought.) The 4 Resident "c/Assign" pure" startup-sequence described above does not conform to this • practice in a meaningful way. Supposing that this is a problem, ;..,• more commands our solution will be to use console control sequences to embed and format informative text within the secondary prompt, and 24 Execute "s/Stanup-sequence"

Here follow three examples of startup sequence scripts re- ,...• etc. written to exploit control sequences: First, Startup:s/Default- sequence: for which the prompt consists of: 1 . Startup:s/Default-sequence 2 .key "ESC[32m:Esc[31m enter usC[132mdEsc[Om=Esc : enter root: to assign C: to volume root I return for Com- [1;32m DEFAULTESC[Om for default startup sequence I mands:c ESC[4m retumESC[Om to modifyESC D=DEFAULT/s, Esc[32mEsc[E" 3 Execute Startup:s/Workbench-sequence in which the colons and the initial instance of the string "root" etc. are rendered in colour 2.

In its initial (i.e., non-control-sequence) version, this script The prompt generated by this script looks something like this: (and its successors) associated command line arguments other

~{ 1361 1M-

D • Q Transactor r.ru. AMIGA SPOIL than 'd' and "default" with a null parameter. Above, that null parameter is transformed into a series of non-printing charac- Full colour, glossy disk labels ters which comprise the control sequence itself. That is, the for 3%" disks placeholder for substantive command line arguements is the string: esc Easy to remove

After all, who ever said that script keywords had to be printing Available as single labels characters? or as pin—feed Se. DaDate • a Run-able Date utility

appears in Commands:s/stamry-sequence, above. DoDate Single Labels FL 15.00 per 100 1 . DoDate Pin Feed FL 15.00 per 100 2 .bra FL 11.00 per 1000 3 ka] 4 FailAt21 POSTAGE: Holland/Belgium FL 2.50 5 Date > Nil: < "NewCon:5/90/629/25/DoDate: enta date Other Countries FL 5.00 (nn-MMM-vv) and/or time (woad); [return] to resume." 7 No postage on 1000+ labels) 6 If fail 7 Execute Deflate 8 Endlf Payment in Eurocheque, International Money Order, DoDare recuises until the user offers satisfactory arguments to or Cash to: Date. N. Praat Sf. Summary Romanlaan 7 NL-4527 BD AARDENBURG Were this startup sequence not interactive, it would still com- The Netherlands prise many statements. Tweaking the order of script statements to exploit caching and command residence reduces, but does not eliminate, the user's time/energy investment. Users who All prices are in Dutch Guilders spend most of their time with a single application will likely Domestic currency is welcome, but feel that an investment of this magnitude just doesn't make please add FL 5.00 for cheques sense. The same might be said of users who, whether by need other than Eurocheques of contiguous memory, or simple habit, reboot on quitting any given application.

On the other hand, users who must manipulate system condi- tions before setting up their application have different usage pattens and may find some aspect of this model worth imitat- ing. Not demonstrated but quite conceivable is the extension of the techniques illustrated here to articulate a decision tree of startup conditions.

As programs go, shell programs am high-overhead and limited in scope. Whether a shell program even makes sense as an ap- proach to a particular programming task depends on the pat- tern of one's computer use and the level of abstraction of the task at hand. Where such considerations point to the viability of shell programming, then shell programs are by far more easily implemented than their C or BASIC equivalents. Their use requires a certain understanding of Amiganos concepts, and the availability of models. It is to the provision of the lat- ta of these prerequisites that this article, and its successors, is aimed. o H ln Transactor to, the AMIGA 0 WordPerfect's new Amiga Workbench

A review of WordPerfect Library

by Jay A. Gross Calendar is a useful program with no direct competition an the Amiga. It would be really helpful for business types. When the After almost a year of updating, WordPerfect on the Amiga is computer is fired up first thing in the morning, the day's Cal- still not nearly perfect, not nearly an Amiga program. Now endar would be displayed, reminding with its Memo window, there's WordPerfect Library, a newborn litter of spotted pup- its To-Do list, and Appointment list, and sounding the alarm at pies from the WordPerfect kennels. appropriate times. Alarm can run independently of the other programs, and its method of attracting your attention can be Basically, WordPerfect Library adds a kit of utilities to the the usual beep, or a stirring speech by the Amiga narrator, or WordPerfect environment so Amiga owners won't have to use any digitized sound. Get it? Any digitized sound. Use your anything in their systems that WordPerfect doesn't sell. Li- imagination and keep life interesting around the old office. brary isn't completely Amiga-esque. Its multitasking is very limited, and it uses WordPerfect's same, incredibly sluggish Calendar offers a facility for calculating how many whats are routines for getting imitation Amiga requesters on the screen. between two dates. How many Sundays, or how many To coin a phrase, the utilities have "no respect." They eat cru Wednesdays, for example, between August tenth and October power voraciously, making multitasking unpleasant even for the first? Amiga user group meetings and other important, re- their WordPerfect siblings. curring appointments can be entered batch-wise with a handy menu. Ignore all the old-tech keyboard entry stuff in those Yet, Library has many redeeming qualifies. There are two and menus and just use the mouse to click where you want to put a half rather nice programs in the batch, and while WordPer- something. It's the Amiga way. The keyboard stuff is a confus- fect software products are not perfect, WordPerfect support is. ing annoyance here.

Library's nicest program, and its most useful, is Calendar, Calendar permits merging its files, and is supposed to flag which itself comprises an appointment book, a 'To Do' pad, a conflicting appointments whether in the merged file or nor- Memo pad, and an Alarm program. These sub-programs ap- mally. In the initial release of the product, this feature doesn't pear in Amiga-looking, sizeable, movable windows and they function; but an update and bug fix is already in the works. can be opened and closed individually; either from a pulldown You can count on WordPerfect for updates - pan of the compa- menu or with a function key (WordPerfect's stock-in-trade). H ny's stellar user support. Calendar's several windows are eas- you have used Calendar on MS-DOS machines, you'll feel right ily configured to personal taste and a "save default" feature at home; the key commands are identical, as with all of the Li- will make them come up that way henceforth. A word of wis- brary programs. dom: if the Library programs ask you for a disk, feed it the disk. Cancelling the request sends an engraved invitation to lust as the kit of windows can be opened from a pulldown the guru under many circumstances. menu, they can also be closed that way - all at once, or by clicking the close gadget on each one. Better use the gadgets. Like other WordPerfect applications, Calendar has a handy The "close all" option from the pulldown leaves several hun- zoom gadget in addition to its front/back buttons. Fully dred bytes of memory allocated somewhere that won't be re- zoomed out, the window occupies the entire screen - even on a turned to your system. Since Calendar is too much of a cru high-res WorkBench - and the program puts reminders on a hog to leave running in the background, you'll have to close block diagram of the current month to indicate whether there and open it repeatedly, too - chewing up bits of memory each is a To-Do list, an Appointment to keep, or a Memo for that time. The least you can lose seems to be 200 bytes. This does day. It will also display a key word from the day's Memo - not count the 26K library that all WordPerfect applications "meeting" or "vacation" - if the display is large enough. The share. The system returns memory used by shared libraries af- display does not adjust correctly to a high-res WorkBench, ter they're freed if it needs the space, and WordPerfect Li- however, and the system font absolutely must be a vanilla brary's .library apparently behaves properly in that respect. eight-line one. Topaz-11 will make a mess of any WordPerfect

F IMI LJ Transactor for the AMIGA 4 4 display window, including Calendar. Using the To-Do list, Ap- dons to keep Einstein, Kemighan, and Boesky all entertained pointments and Memo windows is troublesome with the Cal- and happy. A particularly stellar feature is its window of regis- endar at full zoom, too; since the daughter windows don't pop ters which can remain accessible even after Calculator is to the front when menu items such as "add/edit memo" are se- closed As far as calculators go, Gizmoz (Digital Creations), lected. from 'way back in the infancy of the Amiga, has a neat ap- proach: three separate calculators, one each for Scientific, Pro- Another small problem is that the current time of day should grammer, and Financial, with a storable "tape" that prints to be displayed on the parent task, not on each and every one of screen or printer. WordPerfect's calculators are better, but the subtasks. Forget a fix ever being done on this one though, they're bound into one program that's too unwieldy to leave since WordPerfect's aim in life is to make the Amiga look like wallowing around in the machine all the time. an IM, and the IDM version probably does the same stupid thing. Library's FileManager is a utility for moving disk files around without coping with the cal environment FileManager is well WordPerfect's standard version of the Amiga proportional gad- organized and well done. However, it provides no facility for get is a random block with no rhyme or reason for anything it viewing an am file (predictable, since Ms-DOS has no such does. The arrows don't always repeat; the slider hops around graphics file standard). The program is the least Dos-like of hie an crazed toad, and besides that, no two of the company's the Library applications. Its excellent "Look" option for read- proportional gadgets work the same way - if they work at all. ing the contents of a fie almost makes up for the lack of um Strangely, Calendar's proportional gadget in the Appointments file viewing. The option permits WordPerfect-style searching, window works just about like Amiga ones are supposed to. It's which is a powerful search, indeed. quite a shock. Has someone at WordPerfect Corporation learned to operate an Amiga? FikManager's filename match patterns am not Amiga pat- terns. ARP (Amiga Replacement Project) solves this pattern Calendar is not completely friendly to the Amiga multitasking dilemma by honouring both Amiga ones and the simpler Ms- environment since it soaks up a good bit of the cru's power Dos ones as a crutch. WordPerfect Library speakee only aster- for itself if left parked in the machine while other things occur. iskee. This is a serious failing of all of the WordPerfect programs, es- pecially WordPerfect itself. For example, although WordPer- The program also brings something revolutionary to a Word- fect supports up to 32 (re-entrant) document windows at once Perfect application: interactive file requesting (not to say "Re- the Amiga operates so slowly that it looks like it's crashed af- quester"). Windows of stuff in FileManager are "hot" only af- ter only three documents are running. Library's applications ter a full screen's worth of filenames is retrieved from the disk. cam off the same high overhead, so if you have Calendar, It's a great improvement over WordPerfect, which has non- Calculator and two WordPerfect documents operational, you interactive (read: dumb and slow) filename windows. can go out for coffee and Twinkles while the system opens a window. The documentation for all the programs, as is usual with WordPerfect products, is voluminous, classy, and outstanding. Notwithstanding the presence of front/back gadgets on all of The package would benefit greatly from a script for installing its windows, Library offers in its pulldown menus (as well as on a hard drive; although following the directions carefully the ubiquitous F-keys) a "switch" option. This brings up a should not be too difficult - even for novices - and any prob- window (none dare call it "Requester") listing all available lems are readily solvable with a call to WordPerfect's toll-flee WordPerfect tasks, from which you can pick one to switch to, help line. The WordPerfect Amiga help staff has Amigas in using either the mouse or those infernal key commands. front of them with which to walk callers through any opera- Stupidly, WordPerfect's "switch" option will put up a list of tion if necessary. only one place to go if that's all there is. Moreover, the "switch" window offers only WordPerfect applications as des- Calendar, Calculator, and FileManager are the pick of the Li- tinations. brary titter. Three out of five isn't a bad average, and at a retail of $129.95 US, those three, especially Calendar, are probably The Amiga comes with a free calculator program that sleepOs worth the whole price. You get the others, PEdit and Note- peacefully on the WorkBench until you need it. The Amiga Book, thrown in for what they're worth, which isn't much. Calculator, though, doesn't know hexadecimal, and never heard of Future Value or Suaightline Depreciation. Enter PEdit is a streamlined version of WordPerfect complete with WordPerfect with the perfect (?) solution: another of the Li- powerful macros (the same as WordPerfect's), fast, fabulous brary litter, Calculator. Flick between Scientific, Programmer, and furious search and replace, and some special programmer- and Financial calculators at the click of a mousebutton esque tricks, the hex edit one being probably the most useful. (mousebution? heresy!). Those proportional gadgets mentioned earlier? PEdit's has to be turned on before it bothers you with its presence. WordPer- WordPerfect's Calculator is another pretty pup. It works fine fect's documentation says leaving it off speeds up the pro- even before the first update, and has enough options and func- gram, and it does. Funny, other Amiga editors have no prob-

F1 1391 —e ~

❑ Please send me 6 consecutive Transactor tor the AMIGA starting_ with the next issue! • dm subscribing to the magazine AND the disk. TrVs Ntor E I am already subscribing to Transactor - my subscription p is ma MapmMw M 1TIpe rraaramman

Subscriptions United Kingdom Foreign Mag Disk• Both• Mag Disk' Both' 1 Year 01500 ❑ 38.00 053.00 ❑ 20.00 038.00 ❑ 58.00 Years ❑ 28.0(1 0 7110 098.00 ❑ 37.00 070.00 0 107.00 3 Years ❑ 37.50 095.00 0132.50 050.00 095.00 0145.00

E New Subscription ❑ Renewal (please include your Subscription Number from ma ling label) Name & Address New address? D Mitose include year postal :dot

Phone a :I

All U.K. prices (where applicable inclusive of V.A.T.( . All Foreign prices (where applicable) exclusive of V.A.T.

'UK/Foreign' E 7.95 Transactor Classic Amiga Disk p1 E 24.95 Dedit Version 2.4 (2 disks) ❑ 7.95 Transactor Classic Amiga Disk x2 E 3.00 Guardian 1.2

Note: See News LINK for details on above items Transactor for me AMIGA Disk '£7.95' each. (correspond to issues of Transactor a me AMIGA) D Vol 1. Issue 1 ❑ Vol t. Issue 2 ❑ Vol 1, Issue 3

Fish Disks '£3.99' each. Noier Disks numbers not yet released may be ordered in advance - simply add numbers to end of list. Disks 57, 80. and 88 not available.

❑ 1 0 1 ❑ 33 0 4 ❑ 65 D 8 9 9 0 11 0 12 D 14 ❑ ss ❑ 2 ❑ la ❑ 34 ❑ 50 ❑ 66 ❑ 82 ❑ 98 ❑ 114 1:10 ❑ 146 Os

❑ 3 ❑ 19 ❑ 3.5 ❑ 51 ❑ 67 ❑ 811 ❑ 99 ❑ 115 ❑ 131 ❑ 147 s ❑ 4 ❑ 20 ❑ 36 ❑ 52 ❑ 88 ❑ 84 ❑ 100 ❑ 116 ❑ 132 ❑ 148 E 5 E 2 9 3 D 5 0 6 0 8 0 10 0 11 0 13 9 19

❑ li ❑ 22 ❑ 38 ❑ 54 ❑ 70 ❑ 86 ❑ 102 ❑ in ❑ 134 ❑ 150 SOD ❑ 7 ❑ 23 ❑ 39 ❑ 55 ❑ 71 ❑ 87 ❑ 103 ❑ t10 ❑ 135 ❑ 151 ❑ 8 0 2 D 4 ❑ 56 ❑ 72 ❑ aa 0 10 ❑ 120 ❑ 136 0 15 ❑ 0 ❑ 25 ❑ 41 ❑ 57 ❑ 73 ❑ 89 ❑ 105 ❑ 121 ❑ 137 ❑ 153 ❑ 10 ❑ 26 ❑ 42 ❑ 58 ❑ 74 ❑ 90 ❑ mri ❑ 122 ❑ 1a8 ❑ 154

E 1 0 2 0 4 Œ 5 ❑ 75 9 0 ❑ 007 D 12 0 13 ❑ 155 ss sss sssssssss 0 1 0 2 D 4 Œ 6 0 7 0 9 0 108 ❑ 124 0 14 ❑ 156 D 1 029 0 4 961 0 7 9 9 ❑ 109 E 12 0 14 0 0 1 0 3 E 4 062 0 7 0 9 ❑ 110 D 12 0142 ❑ ❑ 15 ❑ 31 ❑ 47 ❑ 63 ❑ 79 ❑ 95 ❑ 111 ❑ 127 ❑ 143 ❑ ❑ coos s ❑ 16 ❑ 92 E 4 G 8 0 8 9 9 D 11 D 12 144 ❑ sssss

Transactor larme AMIGA Back Issues: U.K. £3.00 (Foreign £3.50) ❑ Vol 1. Issue I ❑ V011. Issue 2 ❑ Val 1. Issue 3

Please allow 6-8 weeks for delivery, 4-6 weeks in U.K. NOTE: Prepayment required. Purchase orders will be accepted ONLY if accompanied by payment. For foreign orders send bankers draft in Sterling funds only.

X E ChequeA4O. enclosed Cheques Dated / / Amount ❑ Please send advertising ndnrmati ❑ Please send dealer information. 08/88 PLACE

STAMP

HERE

Transactor (U.K.) Limited Unit 2, Langdale Grove Bingham Nottinghamshire ENGLAND NG13 8SR

The Deluxe Series of high quality creativity tools from Electronic Arts. A set of totally ,111111 111 Inii inii ii iin1 lÀ integrated packages that is DeluxePaint II with DeluxePrint I DeluxeMusic The ultimate music tool so powerful and so flexible, The world standard DeluxePaint is now for composing, performing and painting, unbeatable with the inclusion of Deluxe- DeluxeMusic features an enormous it is limited only by your Print. With so many built-in artistic tools, variety of playback options Including they'll bring out the artist in you! Midi I/O. own imagination.

a• Alle

DeluxePhotoLab Combines:three DeluxeVideo Rock videos, business DeluxePrint II What you see is what...±. i powerful graphics tools — a professional graphics, cartoons this comprehensive ),ou get. DeluxePrirnt it has seven ready-'. , ! paint program that works in all Amiga video animation package allows you to made page formats for signs, banners, graphics modes including-H.A M:, a make your own stunning videos, without cards, letterheads. calendars and mors! colour image processor.and a poster complicated commands and formats. maker for giant. posters!.:_.

Available now at your nearest Amiga software outlet. More information is available from Electronic Arts, I1/49 Station Road, Langley Berkshire SL3 8YN Telephone 10753149442. transactor vue AMIGA a lem with text speed with a proper Amiga proportional gadget Oh, but if that were NoteBook's only problem. Remember the running. Without the gadget, though, PEdit operates consid- old days, when you had to memorize a bunch of gibberish erably faster than WordPerfect itself. Just don't open more command sequences? Those dog days visit us again with Li- than one window (it allows 32!). For general text editing, brary's NoteBook. The program makes minimalist use of the rather than programming, PEdit will be somewhat frustrating, mouse, and its setup screens are drives by the keyboard in the as there is no way to set a line length for word wrap. That's most un-Amiga manner you could possibly imagine. great for C, but not too useful for truly "personal" editing. Like the other Library utilities, NoteBook supports WordPer- PEdit does not support Amiga's ARE= language for in- fect's print, search, and macro operations where appropriate. terprocess communication. It should. TxEd Plus does. So does Searching for a string within a file listing can be quite handy, ASDG's new CygnusEd. Programmers, particularly, will fad and searching Calendar's files can be useful, too. Macros are ARM useful. Since RBXX, of which ARlna is the Amiga im- always handy things to have, and WordPerfect products share plementation, is an nam darling, maybe WordPerfect can some a very powerful macro language. In addition, if you can ever day be convinced to support its Amiga incatnadon. get past the horrible user interface, NoteBook will generate WordPerfect compatible merge files. These are not difficult to The shabby condition of PEdit shows again that WordPerfect's do in the wordprocessor, but having them done automatically recycled MS-DOS crew hasn't figured out a lot of things about will save time and trouble. the Amiga. For example, multiple select for Bold, Italic, Un- derline, etc., doesn't indicate anything in the menu bar (a Other caveats. The WordPerfect Print program - the same one checkmark is usual). The program accepts multiple clicks as for all WordPerfect applications - is set up as a separate task though multiple selections were being made, but only executes which operates in the background, crashing at the slightest what was first clicked, and does so even if the pointer is re- provocation. If you're going to do any printing, make sure moved from the menu bar with nothing actually selected For you're not doing anything important in the other windows people accustomed to real Amiga programs, this misfeature while it's going on, or save your work frequently, just in case. will be annoying. On the other hand, After almost a year of beta-testing (by graduates of the WordPerfect School the customers!), WordPerfect's Print of Interminable Keyboard Commands program still needs a lot of work. The will never know the difference. Calendar comprises an most crashes will occur in trying to print to a fie, especially to RAMdisks PEdit eats at least 140 bytes of appointment book, `To Do' pad, or recoverable RAMdisks. If the Print memory every time it's called up, used Memo pad, and an Alarm... program locks up, you cannot just a while and then closed down. open another one as you could with most real Amiga programs. WordPer- The worst of the Library user interfaces is on a potentially fect permits only one of its Print programs to operate at once, very useful program, NoteBook. Martians will have no trouble and when it locks up, you'll have to reboot your Amiga before running it. Amigoids will recoil in horror. WordPerfect fans you can prim from WordPerfect and masochists will be ecstatic. Summary NoteBook is a quiche database manager. It keeps track of in- formation, and If you tell it to - carefully, lest the dreaded On MS-DOS machines - those are the ones with all the keyboard 'software error' box appear! - it will dial phone numbers. You templates taped around the function keys - WordPerfect Li- do have a modem attached? The dialing feature is extremely brary lets single-tasking users flip readily among a number of powerful and configurable, permitting any number of varia- applications. The background tasks freeze while the active one tions on a theme. You can, for example, have the program dial is in use. On the Amiga, users are free to choose among a vari- the contents of a field, or dial an access number (e.g., a long- ety of applications from any number of manufacturers, and the distance service) and then the contents of the field, then some applications do not have to freeze in the background. Some- more access codes or extensions, or any number of other pos- body please tell this to WordPerfect In time, maybe, with con- sibilities. The program does little error checking before the tinued hassling, WordPerfect's programs might become more modem is told to dial, and if it's told to do something it can't Amiga friendly, especially in view of the window(mon/mouse do, there will be a problem, possibly even a 'software error' revolution going on in the MS-DOS world. As of now, though, box. A little checking on the string sent to the modem would the Amiga is an environment about which WordPufeet has be nice. Experienced modem users will have no problem, but much to learn. novices will be bald-headed in a week. Although WordPerfect Library is probably worth what it costs, The cryptic, terminally unfriendly menus with which this fea- all of the utilities could be better and probably will be, given ture is set up could be greatly improved, but don't count on it, the company's longstanding reputation for improving and sup- since improvement would make the Amiga program different porting their products. Overall, Library is in fact much more of from the MS-DOS ones (better!), a fate worse than debt an Amiga product than WordPerfect itself. O

H 1421 n Transactor iw xe AMIGA a ❑l Calling the CLI from AmigaBASIC

Part 1 of 3

by Jim Butterfield Copyright @ 1988 Jim Butterfield

Jim Butterfield is a Toronto writer, programmer and lecturer We connect to a library with the LIBRARY function, and when whose association with microcomputers goes back to the 1K we're finished with it, we disconnect with LIBRARY cl.ost. K1M-1 in the earliest days of Commodore computing. JUn's More than one library can be active at a time. But to allow LI- ability to communicate his encyclopedic knowledge of CBM BRARY to work correctly, we need another item: the .bmap file. products through articles, books, lectures and television pro- We'll talk about this in a moment If you don't have the appro- grams has made his name a household word among Com- priate .bmap file, you'll have to make one. modore users around the world. If we want to call subprograms in the library, the LIBRARY AmigaBAsic is a fast and powerful language, supplied with command (with the appropriate .bmap file in place) is all that's every Amiga. It has a large vocabulary and does many jobs. needed. But if we want to call functions, we have another But sometimes you might like to do something that's easier or command that we must call: DECLARE FUNCTION (followed by more natural in the Cu - the Command Line Interpreter. This the function name and then the word LIBRARY). article will show you how. Subprograms vs. functions Almost any program that can be nm on the Amiga can be called in by the CLL So if you can get AmigaBASIC to erns A subprogram is much like a subroutine. You call it, and it the CLI, you'll have the whole machine at your fingertips. But does something. You might compare it to a call such as "GO- we'll need to learn a few odes. SUB DingDong"... you go somewhere, do a job, and then come back. Mom accurately, we might command "CALL Tapping the library xClose"... but the idea is the same.

To connect to the power of the Amiga operating system, you Afunction, on the other hand, calculates a value. If you want- need to communicate with the system libraries. Some of these ed to calculate a squaw mot, you'd use the normal BASIC func- are in the Kickstart ROM, some are in RAM, and some am on tion SQRO. You never use a function by itself... it's part of an disk. You don't need to worry about where they are. All you expression, such as PRINT SQR(16)+SQR(75). need is to get three elements together. A library function must be declared before you use it, with DE- The fast item is BASIC's LIBRARY statement. When you com- CLARE euNcttoN. The most visible purpose of such a declara- mand LIBRARY followed by a library name, BASIC makes the tion is to identify the type of value that will be retuned by the connection to the limer workings of the Amiga In this series function. The type is almost always a long integer, which is of activities, we'll make use of the DOS (Disk Operating Sys- signalled by using the character 'it' after the function name. tem) library. Om command will be: LIBRARY "dos.libmry". Thus, before using a function called xOpen, we would code:

As we move towards the Amiga's operating system, we'll need DECLARE FUNCTION xopena () LIBRARY to develop a new habit case consciousness. In 'regular' Ami- gaBAstc, we can mix upper and lower case at will. It won't You might think, based on past experience with RAMC, that matter if we command "print" or "PRAT" or, for that matter, subprograms are for doing things and functions are for calcu- "PrInT". BASIC knows what we mean. Similarly, we can call a lating things. Not so. In fact, functions are used for almost ev- variable "subtotal" or "SubTbtal"; there's no confusion and it erything in the Amiga. Here's how it works. will be taken as the same variable in either case. File names don't seem to care about case either. But the operating system Let's say you want to do something It open an output chan- is case sensitive; follow the upper and lower case usage in the nel. Sounds like a subprogram, right? Nope. It's a function. listings carefully. We might code: t-I -4 9- jo Transactor for the AMIGA 0 hi = :Open& (stuft about the channel) the whole machine. What we will do is to cause Execute to give the SORT command, allowing us to son a file quickly. Now, when we call the function xOpen& (watch out for the upper and lower case), it opens a channel as we requested, and Program 2, SortCu, allows you to input names. The names are then returns a channel identity to use (called a handle) which delivered to RAMdisk as they are received... the file is called we may use any time we need to reference that channel. If for TEMPO. When you're finished, the file is closed and the inter- some mason it can't open the channel, it returns a value of ze- esting work begins. ro. So we could follow the above code with: We open the LIBRARY We define the function Execute&. Note xv h&r=0 raw pane "Can't Cpm the channel.. ":inn that it is a function, not a subprogram; it returns a value (a boolean 'success' flag). If the handle is non-zero, we have opened the channel success- fully. The handle, by the way, contains an address; we'll deliv- Now we Execute the command SORT TEMPO TEMPI and wind er that address to any other activity that needs to use the chan- up our library activities. All that remains to do is to pull the nel. But you don't need to worry about that, either. Just follow sorted values out of TEMPI and print them for your enjoyment. the rules and everything will work. Cautionary Note The .bmap file This version of the program nuis only if you call AmigaBAsIC Go into Cu, and comtoand: "DIR LIDS:"... you'll see several from the Cu. That is, you start up a Cil and command "Ami- items stored in this directory. You might see a file called gaBASIC" or "Run AmigaBASIC". dos.bmap, but probably not. If you have such a file, skip to the next section. If you don't, we'll have to make one. If you start up Amigahasic from the Workbench, clicking over the program icon or the AmigaBasic icon, the program will Appendix F of your AmigaBASIC manual contains a lot of ob- crash dismally. scum material about .bmap files. We'll talk about this detail in part 3. For now, only the last sentence is important, and hem's To fmd out why, and how to fix it, stay tuned... what it tells you: the best way to get a .bmap file is to dig out your EXTRAS disk (the one with AmigaBAsic), find your way Program Details into the BasicDemos section, and mn program "ConvertFd". It might be worth looking through the code of the SortCLI pro- If you do so, remember that the name of the file you want to gram to see how the call to al works. Much of the program is convert is called DOS Plough your way through it, and after a "regular BASIC" For example, there's code at the beginning to few false starts, you will likely end up with a file named allow you to enter data, which is immediately passed to a RAM dos.bmap. Or... I hate to spoil your fun, but das.bmap is proba- file. There's code at the end to print the contents of the sorted bly already on that disk, in the Basiclkmos library. RAM file. Both of these are straight BASIC.

In any case, the next thing to do is to copy it over so that it's The cede that links to cal may be found in the middle. The also in LIDS:, where it can happily live for ever. You can do first instruction to do the job reads: that with the Cil command: DECLARE FUNCTION Execute& LIERARY COPY en= :Baste:m oe/doe.bmap r.Ias: This line says, "When I use afunction called Execute, I want If all that sounds too complex, you could type in Program 1, the computer to know that it's a library function, and that the Bmap_)aker, which will make a 'tiny' version of dos.bmap value returned by the function will be a long integer". for you. [Note: BMap_Maker and the other programs accom- panying this ankle are also available on the disk for this is- As we noted earlier, Execute is not a command, but afunction sue. - Et] Run the program and it will create the file. There - it returns a value. The value is boolean, that is, it signals ei- will also be a file called dos.bmap.info which is not needed; ther true or false. In this case, it signals "operation surress- you may delete this if you wish. ful" if true.

Getting to CLI The place to read up on all of this is in The AmigaDos Manual. Within the section entitled AmigaDos Developer's Manual Now that you have dos.bmap safely installed in your Las: li- you'll find "Calling AmigaDos" (Chapter 2). and that chapter brary, we re ready to see the trick done. Hem's the secret. has an entry for the Execute function in Section 2.2 under the heading Loading Code. The from is shown as: Command Execute within the DOS library will execute any cu command you give it. That's where BASIC truly gains access to Success = IDenute( -DamniStdnr, input, output )

H ~2 1u Transactor i. p. AMIGA O We'll set the command string, set input and output to zero, call The format for Open I.S. the Execute command, and will receive back a value for suc- cess. Soon. But fust, we have to open the library itself with: handle Open( nase, Aacessllode )

LIBRARY "dos .library" The name is a string, and we'll handle it the same way as we did for Execute, that is, we'll terminate it with a zero and sup- Now for the actual call m the cu: ply the address of the siring, not the string itself. The Access- Mode has only three useful values: 1004 for opening a file for smEzecute5 (SADD("sort >nil: ram:temp0 read and write; 1005 for opening a file for read; and 1006 for ram: templ^+CER$(0)), 0, 0) opening a new file for writ And handle is the value we'll get back, allowing us to identify the file. It will be a long integer, The command string is enclosed in quotes, and must be fol- so we must remember that when we define the function. lowed by a NUL, character; that's how the system detects the end of the command. We supply its address. We have set input So here's the plan: We must remember to DEFINE FUNCTION and output to zero. The call to Execute will return a "success" for Open (it's in the same library as Execute). When our call signal, which we'll put into variable z... and never check. to Open gives us the file handle, we'll supply that handle to Execute. Now that function has an output path, it will be hap- Now that we've done the job, we wrap up with: py even when called from Workbench.

LIBRARY CLOSE One small problem: the file dos.bmap does not contain a func- tion called Open. Instead, it has a function called xOpen. From this point, we continue with 'regular' BASIC. That's for a good reason: OPEN is a BASIC keyword, and Ami- gamic would be confused if we used it. So we'll use xOpen Where's the bug? (and, later, xClose), but we'll drop the 'x' when we read the documentation. That's all very well, but why won't this program work from the Workbench? Let's read further in the documentation for So we're ready to type in Program 3, SortWa. This time, it will Execute: do the job no matter how we calledAmigaaASIC.

"._m most cases the output file handle must be provided, and The .bmap files will be used by the cu commands as their output stream un- less redirection was specified." Now it's time to look more carefully at the .bmap files, which hint at the workings of the Amiga, and to put together a pro- Well, SORT doesn't need an output stream. We tell it where to gram showing the variety of ways we can use CLI to do jobs put the sorted file. Let's keep reading: for AmigaaAsIc.

"...If the output file handle is set to zero then the current win- In some ways, the structure of .bmap files reflects the structure dow, normally specified as', is used. Note that programs run- of the Amiga itself. It's worth a closer look, and the program ning under the Workbench do not normally have a current Bmap_Snoop (Program 4) will do the job for you.

Library structures There it is. We need an output window, and the Workbench doesn't provide it. Even though we never send anything to the The Amiga contains a number of structures called libraries output window, it must be there. that make the inner workings accessible to programmers. The- se libraries contain a number of interesting things, but the part So let's set up an output path... even though it will never be we're interested in right now is called a jump table. Ajump ta- used. I'll setup an output to NE.:... whatever goes there will be ble is a series of 'jump' instructions that tell the computer to thrown away. This is a type of double negative: we're sending go to a certain place to do a certain job. nothing, and throwing it away when it gets there. But it satis- fies the need fir an output path. Each library has a different jump table, customized for its work. The DOS library, for example, contains the entries we Opening the path have already - Open, Close and Execute - plus many others such as DeleteFile, Read, and Lock. Each of these functions In the same documentation, you'll find details on the Open occupies its own special slot in the jump table. function which, you'll remember, returns a value called a han- dle, which we will use). We'll use it to open a path to NB.:... A library has a 'reference point', or address, which locates it, Is, we'll wind up the path with subprogram Close. Note that but this address is not at the start of the library structure. M- Close is not a function, and we don't need to declare it. dresses above the reference point usually hold data of some

H 45 ~ ln Traroxtor tor da AMIGA 4 ~ sort. Addresses below the reference point contain the jump ta- But you will notice that there are lots of functions. It takes a ble. So don't be surprised if a jump table entry is shown at lo- lot of time, and a lot of reading of manuals, to gain an appreci- cation -60 in its library that's where such entries always lie. ation of what they all do.

So what do we need to know, in order to make the connection? Program DirMake We need the name of the library (in our example, "dos.librery"). Each library has its name built in. So a com- To tie this together, I've written program DTMake (Program mand such as "LIBRARY "dos.library" will cause BASIC to ask 5) to show several ways of using the BASIC interface to c a the operating system to look for the library of that name and The program does something that's not easy to do in BASIC... it report its location. Yes, it can move around - but not while creates a new directory. you're using it. The first call to Execute invokes the at command Prao. The If we've found the library, thanks to the LIBRARY command, output is delivered to file ,AM:temp, and it's used to spot the we must now find the function we want to use: Open, Exe- currently active devices (disks, RAM, whatever). Select the one cute, or whatever. That's an offset within the library... but you want which is which? File .blimp comes to the rescue! For the first call, we include the cu command right in the Ex- The .bmap file contains the names of entries into a given li- ecute line. brary, and the 'offset' for that particular function. The offset is always negative. There's one other piece of information in the The second call, which may be repeated, looks at a given di- file, but we'll come to that in a moment rectory, using the CLI command DMR, ro see if there are any subdirectories within it If there are, it allows you to choose Function Open, for example, is first in the dos.bmap file, and one if you wish. If you do so, this section will repeat is shown to have an offset of -30. Function Execute is last in the file, and has an offset of-222 (it's a big jump table). For the second call, we form the command string separately and then reference it as a variable from the Execute command. With the name of the library and the .bmap file, we can go di- rectly to the part of the jump table that we want There's only one The third call uses the co command MAttEDIR to make the de- more thing we must sort out how much data must we pass to a sired directory. For the sake of variety (and to show you that it function? Some functions require no dam.- others reed a whole can be done) we put this command into a script file, and ask collection of information, and this information must be carefully Execute to ran the commands from to Fore. There's only one arranged in the 'registers' of the processor at the time the function in this case, but a whole series of commands could be execut- is called. How can a BASIC program sat out what's needed? ed if desired.

Again, .bmap files provide the answer. In addition to the offset Summary value for the function, the file also carries information on how the data should be set up in order to make the function behave Using the magic of commands LIBRARY and mums FUNC- properly. A list of registers is supplied to indicate to the inter- TION, and the elegant .bmap file, we can add a great deal of face what information should be provided where. The registers variety to BASIC. may be marked 'D' for Dam register, or 'A' for Address regis- ter, followed by a number from 0 to 7. And in doing so, we can also gain more insight into the work- ings of te Amiga. Don't worry about what the register does The computer will take care of that You'll find it useful to know that a register may con- tain an integer value of up to many millions, ora mangy ad- Rat apt a ad4.rfSald dress. If a mumu can do the job, you'll likely use it directly, if a string is called for, you'll supply its address (and laminate the DM 120,19,112,101,110,0,255,226,2,3 siring with a Nutt-character to signal its end). DITS 0,120,61,108,111,115,101,0,255,220 DIM 2,0,69,120,101,89,117,116,101,0 Program Bmap_Snonp 12TS 255,36,2,3,6,0

Enter and run this program. k prompts for the name of some FOR jm TO 36 popular .bmap files. You may select one of these, or enter your RYO v own name. bth 44.140100) The program will print out the names of the functions within j the library, the offsets, and the registers that are needed. That's a 403128 11m PRL! •1211 EDW:® all there is... no secret code, just a simple table. BLS Mao file adb.:de..tmp> ...• 1461 ~

HI Transactor or o. AMfGA OPU •liba:da.0ap• fa 0060E 18 #1 MULL n00•• PKIR11,i0; f2D112,n0 CLOS #1 v t1 Pier: •fil• dib.:dw.bmp> written' SIR •Ra••rn.. Lin InaS

CLOS▪ & IP - mi. die prays .hon how to PRO 6ü - Stet. Itga malte routine 2111 'sorting anisa... •r ID - from LSO.-BIKIC RCTIU PRLTIa ami LOUT MURK PBBCLfa awes MIMIC PRI! Oa sorte dae ... JL Butterfield" MUM paGKIa momt.i LEON ' This wort. with 1br"—" w CTS PER Ret.r • umber of amr... • , www it creates its am m: owipot PRI! Tlntt with • blank lis. • LIM= •dw.libazy CPHI •m:t.RO• is O060T L #2 •08010) n•1 badlda+Opei(Bla(zn:'+lS),9a1'BOce 6112712v0)) PUB •Bo••:n. . D hadlao0 !Bn Lier DM 4 retreautsitUDDreort rattail m:tapl•+s0), 0, handle) Iii 40•• zCion(Lndla) PpDlp,4 ¢a °a1 PAM 'couldn't handle fil. i/e• PAIR •B0•;a, . , ID D LLS IRR al Limier CLOS SI pAO2 •... sort oagl b,.• ©CRM PRIT • Ilea an the na..: • PRIE CPU •LB:t.RL• Pa re IS 1 PUN 'sorting noes..."; I L i RO! Ra(1) IOU= 70101101hsoute LUPUS LLS 5402 11,•0 PHI — me sat line only net. min BSwake— wake CLL, not Borklach LOIS •dw.libaty CLOS arat.h181DD1'sorttr )t l: m:tap0 ra:tapl•+mt010)), 0, 0) KILL 11211:tap0• LISIR CWS ULS •m'tamp1. PRI T •... sort ca plet..• PRIE PM • arts• an . mu: • Om •er0:tapl• Pa ISR 22 1 SIS RR HM(1) LIS 1602 11,4 SD! .0 PRI! • BIM Looker - OL n,e...a.ra• PRO CW▪ S 1¢I1 •BLl:tor DRh dihfont,dw,pWihlo.,.ac,otb;and KILL "Patapl• mD fO PRIS f-0 ID min 40'eay' d+1feL+ D f0••othu• 6S PER fl' other' RC1 - dao program .hows has to UM ort - Stet. mm• ZOOM =tin. PRIT f; • :1lbo/•:4: •.L.p' BHI - from Lip-BASIC ID D IUD PER •R® mortar ds ... Jim Butterfield' ® ohS PRAM inter • number of mos..' MILL de a m)f PROS •Platt with • blank lia.• IRR "Your oboiw•:oh CPU •ra:tapO• M COW her ix I® W D ehtf T® NOT 7r•;n, RR~ LIS ISR oS toe Took F -1. Transactor n,ina AMIGA 4 a MD fit lia •m:enR• ~i F•-1 mh':1ib./•HS9.1inp• WIZ pc0apin Ga PGR •Sous choice 10 to•;a:')•; pla! •InGr tNl .bap file am: •: tipi! p LIB MOT gig CID Ga IF pa0 f® QB aaa ra ROt I0 IS Milli p00 bfila=SBR01lA(1),1) rnan9(P) CLOSE 11 BR algal ca.h•ba>m:tap 4111.14Y opt Cul aM0M5(0) armoto6(66bb(Csi), 0, an616 ) SOW araalbfiio0) 4(0)•+11a •11..mflg®e mfua, •114),0) aB •ra:• 6a DaR AS a Bal ian @fil40,•14r,or1.-1);flb(25); of ab W i paOD (1/1ll40, •1rw•14r, R) ) UM PT en(1)

B7R MSG •IFFF •;of.si; LR INN 81,4 omen 144•. . p.rgWm1•1vlf 4W4b1a)aa0 W,6,laZp)-11)r•/• pouiOCPfap @f flak putt) ) IUD CLOW 11 Bai pag0 . p4vg4:1 ma •m t.q a pW7 18B N0fe0 ... os,• bdl.p•9•ICB01f0rp.a-p) POR 0;7i14 8 Toe j4 TO a CUM hadla=•D'ICeO MOP* BURT i;afi) MOT ® a pun ap)aadlM; P0-1 Bili pc0 CO pg noeh",• MR 'Far elnin (0 tn•:n; •)'; pealGpBPtr1 IBO! p pastille MO) 1bfila,posit) ) Wn ® Ga pony •1swpnPtil P4 ® ®a rilaal(p) GO BR PGR 'M'a going to pd a no DinitcrS (Dram)" ROI - ffin del prorate gon ha to POR 'into nraa •;Rla - invoke hdga @C98 outgo IRD! aca•:4 1031- fm Mg4-BASIC a :rye a rhYn4• fHU Da 41201 _ IIR , •m4 of or dinctorS':Ia.O PRIM 'Tatra aka a dlaotorS... RB "raker Ea COON a0 11 WCmW MOM a0poo6 =UM PGR •;6114;1141 DlGill yvcrla treutaa LOOM at. 11 moan •da..libmS• POO 'Waking disakosS 6:ri1N:IW 4h421)0) ' Soo n w a mint fila... a.eA640pa6 (WpD(•GL: •M0),1006) Badlfra0pai (Wn rug tap•h),1005) a•Gadog (0hn('iaro >m:tanp4a), 0, baadl6 ) if e.mz6o0 »m @B 'attar Toe ISO 1I Il nasulas10>a(4), Dad16, paint ) PRIM Or< nog > xC1a1184o410 10IDi Or Of (1) ILO Zia aPR K,:O PPO! 'Tailed! Cooldo't badls fila i/o' Zr rG18(4,/,1)•":• !>m ® a na/1 ® If 010.141119h0,11) GLL 'aa:ra.p. BaF in (n) MSS Fila ®a ® a 7® scions07ad16) 151 Mae II =MU CLOTS 4- 1481 -8I1 lu homuctor m, re AMIGA d

Superbase Journal

Hints and tips for Superbase users

Superbase Professional is now a popular database Now any months? management system. Although It has its limitations, It la powerful and relatively easy to use. This and Calculating the number of months between two future Superbase articles will provide a forum for dates may seem easy, but the MONTH() function in-depth information on the inner workings of only extracts the month number of a date. Superbase and a source of hints, tips and program Therefore: examples for the programmer and end-user. The information in this column is compiled from several MONTH (datel - date2) sources, principally the Superbase Journal produced by Precision Software, distributors of Superbase and will clearly not produce the correct result. It is is reproduced with their permission. possible to set up a relatively simple formula to calculate the number of months between datel and date2: Dow OM the exist? ABS (( FEAR(datel) - YEAR(date2) ) • 12 + It is often useful to know whether or not a file NO$TN(datel) - MONTE(date2)) already exists. One way of doing this is to use the ON ERROR command to set a flag if an attempt to Using the SER() Tmctton OPEN the file fails. The SER() function generates a serial number for a t$ • "temp": GOSUB exists record. It is stored as part of the file header, and IT exists% TM T "File exists" is incremented every time a record is stored. There ELSE t "File does not exist" are several quirks associated with the ER() function; END IF the following explores a few of them.

exists: _The serial number generated by SERO represents exists% - 1 the total number of records that have ever been ON ERROR 00T0 nofile created for that file - It does not represent the OPEN ES FOR INPUT current number of records (the RECCOUNTO func- ON ERROR tion does this). CLOSE INPUT RETURN Although SER("") can be used to return the next serial number for the current file, in multi-file not11e: applications this may not be the same file that data exists% is 0 is being entered into. Therefore It is advisable to RESUME NEAT use SER('filename"), explicitly naming the tile.

The subroutine 'exists:' sets up the ON ERROR trap. This in itself may cause problems should a file be and then attempts to open the file whose name is reorganised, since the REORGANISE function nor- In fa. mally insists that the new file has a different name. This means that any explicit references to files will If it falls, the routine called 'nofile:' is called and not refer to the correct file, and all references will the value of the flag 'exists%' Is set to 0 (FALSE) need to be changed. However, by putting the re- otherwise it remains set to 1. organised file in a different directory or on a dif- 4-1 ~~ 10 Transactor formeAMIGA ~ ferent disk, the same filename may be preserved REORGANISE of the file. If this is not desirable, It and the newly reorganised file copied back to the may be possible to REMOVE the index, and then original disk if required. regenerate it using the NEW INDEX option. Another problem associated with the REORGANISE function is the fact that the serial count in the SUPERBASE error deleting key 100: header is reset to reflect the actual number of Superbase cannot find the specified key in the records in the reorganised file. Therefore, if records bottom level of the index file. have been deleted the serial numbers will no longer match, which may cause problems. SUPERBASE error deleting key 101: The key was found in the bottom level of the In batch mode, the serial number is incremented. Index, but the key did not point to the current but is not written to disk until the end of the record. operation. As a result, if batch mode is terminated early for any reason, the serial number in the file SUPERBASE error deleting key 102: header may not be correct. An empty index block has been deleted, but Superbase was unable to find the key that point- Using Process Remove to delete all records in a ed to the deleted block. file, the serial number will be reset to zero. How- ever, when the records are individually deleted SUPERBASE error deleting key 102: using RECORD DELETE, its value is preserved. An empty index block has been deleted, but the key was not pointing to the deleted block. Finally, there is a bug in the SER() function. If you modify a record which contains a reference to Type 200 errors occur when reading data, and are SERO, and then store it, the serial number will be designed to cope with the possibility of an Index changed to the next in sequence. If you then go on rile becoming corrupt and having an entry pointing to select and modify another record, this latest to an invalid data block. record will take the same serial number - a full UPDATE across a complete file will result in every SUPERBASE error reading block: 200 record having the same serial number! Superbase has just tried to access a data block which has been marked as deleted. To get around this problem, it is necessary to prevent a field containing a serial number having a SUPERBASE error reading block: 201 new serial number assigned to it once a serial num- Superbase has just tried to access a data block ber has already been assigned. which is not the start of a data record.

To do this, use the ternary operator to check if In both these cases, the index file may have become anything has been allocated to the field already. If corrupted and the pointers no longer point to valid not, set up the serial number - otherwide leave it data blocks. Alternatively (but less likely), the data set to its original value: blocks themselves have been corrupted. It it is possible to successfully access the record using a (aerialNumber = 0) ? SER("filename"): SerialNuaber different index, then the data record itself is intact and the problem is with original index. In this case, Superbase System errors the solution is the same as for type 100 errors.

You will sometimes find that Superbase throws up On the other hand, if other indexes fall to access some mysterious error message, such as: the record successfully, the data file itself is cor- rupt and a REORGANISE is needed. This should SUPERBASE error deleting key: 100 clear the problem, and it will report if any data has been lost in the process. There are two categories of these system errors. Type 100 errors relate to problems encountered The LOOKUP problem when deleting keys from index files. These key entries are deleted whenever a record is deleted or The LOOKUP function is one of Superbase's most when an indexed field is modified and the record powerful means of data validation, but it can cause saved. problems under certain circumstances.

With type 100 errors, the index file is likely to be When data is entered into a field which has a corrupt and the safest solution is to perform a LOOKUP validation formula attached, the data is F lu Transactor ae the AMIGA o~ used to access another file (the secondary file), BRRNO and ERRN using the data as the key to select a record. The success or failure of this process can then be used Although Superbase has the ability to trap errors, to determine what should happen next; perhaps an and identify the cause of the error using the vari- error message will be displayed or some other able ERR. the manuals do not list the codes with action taken. the corresponding error messages. This is relatively simple to overcome, and the following program can Following the LOOKUP operation, the selected be used to generate the list: record from the secondary Elle is held In memory and its data can be accessed by formulae within the FOR i = 0 TO 250 current file. Unfortunately, the LOOKUP operation 7 i;ERR$(i) is only performed when a validation Is performed, NEST i and the validation is only performed if there has been a change to the field data. Therefore, entering ON ERROR and MONO data Into the validated field in a new record, or modifying the validated field In an existing record While on the subject of errors, It should be noted will cause the LOOKUP function to be Invoked, and that RESUME, RESUME NEXT and RESUME label: the correct record from the secondary file will be can only resume program execution at the begining held in memory. of a program line and not In the middle of a multi- statement line. Therefore, statements likely to cause If the validated field is not modified, then the errors should be placed at the end of program Unes. correct record from the secondary file will NOT be held In memory and any references to this record in This could be used to advantage if it is required to calculation fields will access the wrong record. omit a series of commands should a preceding Since this can occur at any time when a cross-file command fall. reference is unvalidated. it means that the problem can occur both in the course of normal data entry Keyboard shortcuts or during the UPDATE process. This neat little method of cross-file linking is therefore unreliable Not all menu options In Superbase have keyboard and not to be recommended. shortcuts. It is easy to use Right-Amiga/S to save a record, but there is no for DUPLICATE. There are two basic solutions to the problem (apart from setting up a multi-file form with proper links Luckily, a program on FISH disk 79, called ADD2 between the flies). can be used to add keyboard shortcuts for any of the Superbase menu options, or to change (or even The first is simple, but awkward, and simply relies remove) existing options to suit the application. on the user ensuring that he modifies the validated field (simply typing and then deleting a space would For instance, to provide a keyboard DUPLICATE be enough), thereby forcing the validation to take command, call up a CLI. (If necessary, call up the place. command requester (Right-Amiga/A) and use CALL "NewCLI"). This CLI (which may be on another The other is perhaps a little more cumbersome, but screen If SSpro came up on a custom screen) then is reliable and is the recommended technique. When- allows access to the program ADD2 on FISH 73. ever a field from the secondary file Is referenced, usually in a calculation field, create a ternary calc- To ivoke it, put FISH 73 into any drive (here ulation for the field with an implicit LOOKUP assumed to be dfl:) and enter: function: dfl:add/add2 Superbase: 2 4 G LOOKUP( field.current, field.secondary) ? data.secondary: 0 This will add the shortcut

Of course, the data.secondary field could be incor- For further details of this technique. check the porated in whatever calculation formula is required. documentation provided on FISH 73.

4- Transactor k(thR AMIGA a a~

"LUCAS" For the Amiga 1000

A 68020/68881 platform board

by Brad Fowles

Brad Fowles is a design engineer at Anakin Research, and is If you own an Amiga 1000 and you would like to experiment responsible for the hardware design of Anakin's Easy! drawing with a 68020 and 68881 combination to improve performance, tablet. He has been involved with the Amiga since the ma- this may be the cheapest way to get there. Unfortunately, the chine's debut in 1985. Brad tells us that one of his guiding de- chip set is going to cost you about $370.00 Canadian. Our aim sign principles for computer hardware is. 'Don't let out the is to make the rest as cheap as possible. You should be able to magic smoke'. Be careful of this if you attempt this project. be up and running for under $475.00, or about three quarters of that if you live in the real world. Most of you in the Amiga community are well aware of the wonderful software available in the Public Domain. As a hard- I decided to do this project for three reasons. One, I wanted ware type I have often been envious of the ease with which one myself and couldn't afford the commercial versions, Two, software can be shared among developers and users alike. some friends of mine who are using Sculpt 3D and Animate Ideas and techniques can be distributed through BBS networks from Byte by Byte (both are available in 68020-68881 ver- to the general benefit of all. In contrast, hardware developers sions) needed more horsepower to render their images fast lead a comparatively solitary existence, the exchange of ideas enough to actually make money at it. Three, I figured all of us impeded by economic and logistical problems. Amiga 1000 owners out there with true hacker's hearts needed some light in our future since 1 meg of chip ram ain't. Can there be such a thing as Public Domain Hardware? Obvi- ously no one can give away printed circuit boards, but perhaps When I started the design of this board, I used as a reference we can do the next best thing: give away as much information an article from EDN, January 9th 1986, pp 216-219. While as possible and make bare PCBS available for as close to cost looking at this design I became aware of an application note as shipping allows. from Motorola AN944/D, MC68020 and MC68881 Platform Board for Evaluation in a 16-bit System. I recommend both The project is a platform board called LUCAS (Little Ugly these documents, especially the latter, if you wish a better un- Cheap Accelerator System) which replaces the 68000 in your derstanding of how this board works. Unfortunately it is im- Amiga 1000. LUCAS provides greater system performance and possible within a short article such as this one to give more allows the use of the 68881 math coprocessor as well as an up- than a brief overview of how the board works. In the technical grade path to 32-bit wide memory. section of this article, I will try to highlight those aspects that are specific to the Amiga, but a thorough understanding will The board has a 68020 and 68881 running at 16 MHz, and in- require some digging on your part. I also recommend the Us- terface logic (consisting of four PALS, four discretes, a 16 MHz er's Manuals for the MC68020 and the MC68881 which am crystal, two SIP resistor paks, and some capacitors) to trans- available from Motorola as "MC68020UM/AD" and pose 68020 cycles to 68000-like cycles. LUCAS also has a con- "MC68881UM/AD" respectively. nector which will allow you, at a future date, to add 32 bit wide memory. (I'll try to get the fine people at Transactor to Okay. Here is the disclaimer: If you get one of these bare publish a memory board for this system in a few months.) boards and carefully put it together and then install it into your Amiga, you should have no problem and you'll be up and run- You can order the bare printed circuit board for $40, and the ning in an evening or two. If you have problems, then it's up four-PAL chip set for $25 (see ordering information at the end to your ingenuity to solve them. If you don't have some expe- of this article). The rest is readily available from local suppli- rience with a soldering iron, please, don't let this be your de- ers. The schematic and PAL equations are published here. Any- but. I will gladly help anyone with problems. There are three one who wants the film plots or Net lists so they can adapt the ways you can get in touch with me: USENET at form factor to the is welcome to them for whatever [email protected] (Brad Fowles), SIX in the it costs me to get and ship them to you. (PCB design was done ANAKIN, AMIGA conference or by regular mail through using P-Cad on er.. an AT ( ...almost said the I word )). Transactor. If you do manage to get my phone number you'd

~1 1521 4 JD Transactor rerun AMIGA 4d

better be able to sweet talk me within 30 seconds. I hope that Whetstone: if there is sufficient interest out there that local user groups or 68000 24 kwhets/sec. individuals will add their help to anyone having problems. I LUCAS 126 kwhets/sec. have no objections should anyone get the bare boards and put them together and install them for a modest price, but please Calcpi: remember that the purpose of this is to make these available to 68000 4.85 kflops/sec. Error -1.39e-11 end users as cheaply as possible. LUCAS 11.9 kflops/sec. Error -2.78e-11

If I haven't scared you off, please read on. If I have, well... so Float long, and thanks for all the fish. 68000 10000 iterations 45.74 sec. 256000 iterations 286.96 sec. Once you get one of the bare boards and procure all the pans. LUCAS 10000 iterations 12.80 sec. follow the enclosed instructions and carefully solder sockets 256000 iterations 118.56 sec. for all the ICs and the crystal onto the board. Solder the resistor paks and the capacitors into place. Insert the 64 Pin header for Of course, speed could be further enhanced by using inline F the 68000 socket and solder it in. instructions for the floating point stuff, and even further en- hanced by using 32-bit wide no-wait-state static memory. Installation is quite simple but should be carefully done. Re- move the plastic cover and the EMI shield from the Amiga base Please remember that benchmarks are like political speeches; unit. On the right hand side of the PCB, just beside the Expan- they only seem to make sense. sion connector, is the 68000 CPU. Gently pry the 68000 out of its socket, and store it on a piece of styrofoam somewhere safe. Now insert the LUCAS board into the 68000 socket, being Software Considerations careful to ensure that all 64 pins are correctly inserted into the socket. If you want to be really careful, remove the disk drive Most software runs just fine on the 68020 but there are some so you can see better. Watch the ribbon cable for the internal programs which will guru on you. One of the major reasons disk drive, as the bends in the cable can make things awkward. for this is that on the 68020 all the instructions that are on the As long as you're careful and don't force anything, you should 68000 are implemented with the inevitable exception of one: have no problem. You can do initial tests with the cover off, the MOVE SR cea> instruction. On the 68000 this is a user but once you're satisfied it's working put the base unit with its mode instruction; on the 68020 (and 68010 and later pans) it EMI shield back together again. That's all there is to it. Your is a supervisor mode only instruction. i.e., if it's executed on a heart can now resume normal operation. 68020 in an Amiga, you get a privilege violation gum.

You don't need to know a great deal about the inner workings If you're writing software, don't use this instruction; use in- of the LUCAS board to enjoy using it, but for those who would stead the GetCC() library function which translates to a MOVE like a better understanding of the nature of running a 32-bit cc on the 68020, which is a valid user mode instruction. 68020 in a 16-bit 68000, read the section at the end of the arti- This function translates to a Move SR if there is a 68000 cle to get the key technical points. in the Amiga. This way you're safe both ways. (To mn exist- ing software that fails on the 020 for the above reason, you can solve the problem by first running a program called DeciGel Benchmarks that traps the offending instruction and does the right thing. DeciGel can be found on the TransAmi disk for this issue, or To give some idea of the performance improvement you can on Fish disk #18. expect with the 68020-68881 pair, I have used four programs Al Aburto made available on the DEVCON disks distributed at If you're one of those people who thought encoding informa- the Washington Developers' Conference. These benchmarks tion in the upper eight bits of the address field was a nifty idea were run on an Amiga 1000 with a 2 Meg Microbotics Star- ... Oh well, time to learn the error of your ways. board memory board and a Comspec 20 Meg Hard Disk. The operating system was Kickstart 1.21 and Workbench 1.3 Gam- Of course, if you use any instructions from the 68020 superset ma 7. It should be noted that when the 68020-68881 pair is in- then this code will never mn on a standard Amiga. For further stalled, the new IEEE math libraries which support the 68881 information, see section 21 of the Washington Amiga Devel- are used for floating-point transparently. I ran these bench- oper Conference Notes, Software Issues in 32-bit Amiga Sys- marks first with a standard 68000 and then with the LUCAS tems by Dave Haynie. board. The new release of 1.3 has new IEEE Double Precision Math Savage: Libraries which take advantage of the 68020-68881 pair if it is 68000 470.0 sec. Error -6.9e-7 present, and can immediately speed up any existing programs LUCAS 14.5 sec. Error -5.7e-4 which use the math libraries.

~Ji H BJI jo Transactor for the AMIGA 4 ❑ j If you want blindingly fast floating point, the best way is to re- Technical Discussion compile your code so that it uses direct inline F instructions. On the disk that comes with the PC board, you'll find pro- Once the LUCAS board has been installed, we essentially have grams called Mandslow and Mandfast. They are slight adapta- divided the CPU time into two discrete blocks: One, seem- tions of RI's original Mandelbrot program, adapted by Eric ingly operating at 7.16 MHz and synchronous to the special Haberfellner. Both programs am the same except that Mand- purpose chips responsible for the video, sound, etc. and two, a slow was compiled for a standard Amiga, while Mandfast was 16 megahertz asynchronous system between the 68020 and compiled to use inline F instructions. Using Mandfast, a mod- 68881 and any possible 32-bit wide memory connected to the erately deep Mandelbrot that runs in I hour 20 minutes on a LUCAS bus. standard Amiga nuts in 4 minutes 20 seconds with the LUCAS board installed. The essential design criteria I used for the board were that it

should be able to run asynchronously to the Amiga clock (so Compatibility speeds of 16 MHz or greater could be achieved) and that there be no connection other than through the 68000 socket (to sim- The Lucas board works with all the expansion boards I have, plify installation.) but I'm sure there will be some out there that will bomb out. I will keep a list of those that do and those that don't and post it In order to achieve this, the board must look like a 68000 (4 regularly on Usenet and rax. The ones I have are the Comspec clock standard bus cycle) running at 7.16 MHz when it is run- 20 Meg hard disk, Comspec 2 Meg Memory board, EASY., ning its bus cycles, but when it is doing internal processing or and the Microbotics Starboard 2 Meg Memory board. talking to the MC68881 or future 32 bit wide expansion ram, it should mn at the full 16 MHz (3 clock bus cycle). As a matter of interest only, the board works fairly well at 20 MHz, but periodically bombs. I have only 16 MHz parts; when 90% of the problem in making this board work comes down to I debug the bomb it seems to be the fault of the on-chip in- the problem of making the 68020 appear exactly like the origi- struction cache. If you have 20 MHz parts, try it and let me nal 68000 it replaces as it has been used architecturally in the know. Even if you have 16 MHz parts, it's worth the price of a Amiga, but able to go like stink when it gets the chance. 20 MHz crystal to see if it will work. Who knows? You might get lucky. The address and data lines are easily implemented, as they are connected directly from the 68020 to the 68000 socket. Note Conclusion that the 16 data bits are connected to data bits 1)16 through D31. The upper eight address bits on the 68020 are simply left The performance of the Amiga 1000 with the LUCAS board in- unconnected. stalled will be improved, but it won't perform miracles. For general purpose computing, I find that compiles are only about I have used the * convention to indicate low true signals for 1.4 times faster, hardly worth the trouble. However, any pro- ease in typesetting the article, i.e., *AS means AS is a low true gram which uses floating point will be improved considerably, signal. The PAL equations are written in Ctnn. format so I ap- and those which have embedded F instructions will indeed ap- pologize to all you PALASM users. pear miraculous. 68020 to 68000 Interface On the other hand, the board does allow for 32-bit wide expan- sion memory, and if installed you can expect considerable gen- The 68000 has an asynchonous bus structure. It assns Ad- eral purpose performance improvements as well. I plan to de- dress Strobe (*AS) to begin a bus cycle then waits for the as- sign two boards: one with standard 100 or 120 ns DRAMs and a sertion of *DTACK to end the cycle. This is usually 4 or 6 cy- second with some high speed static RAM for no-wait-state cles, but may be held off by some peripheral device. The operation at 16 MHz. You get most of the performance in- 68020 works much the same way except there are two crease by having the memory 32 bits wide, but I can't resist *DTACK-like signals, *DSACKO and *DSACKI. Because the seeing how fast it will go with no wait states at 16 MHz. 68020 can address in bytes (8 bits), words (16 bits) and long- words (32 bits) it must be able to differentiate between them. Stay tuned to TransAmi and the Nets for updates. Enjoy! It does this by use of its dynamic bus sizing capability. A pe- ripheral responds to a bus cycle by asserting one or both of the ***** *DSACKx signals which tells the 020 the size of the transfer. Brad is making the bare board and the PAL chips for this pro- ject available at a nominal cost: $40 for the board (which DSACKO DSACK1 TRANSFER SIZE comes with a disk), and $25 for the four PALs. You can order directly from Brad at the following address: 0 0 32 bit transfer RB #5 Caledon East 0 16 bit transfer Ontario, Canada 0 8 bit transfer LON IEO D l Insert Wait States F u j-i

lE Transactor or he AMIGA

Bus cycles on for the Amiga are always 16 bits wide so we 68020 to 68881 Interface will assert only *DSACKI when responding to Amiga cycles. When we are running cycles for the 68881 (FPU) or 32-bit The MC6888I chip select (*CS) must be decoded from the wide RAM on the LUCAS board expansion connector we must 020. The 020 generates a Ill on the Function Code pins (CPU assert the appropriate *DSACKx combination. Space), a 0010 on the address lines A16-A19 which means this is a FPU coprocessor cycle, and a coprocessor to on Address In general terms with no wait states the 68000 will run a bus lines A 13-A15. Since there is only one coprocessor in this de- cycle in 4 clock cycles; the 020, however, will run the same sign, A13-A15 are undecoded. The rest is decoded by PAL U4 bus cycle in 3 clock cycles. To correct this we must delay *AS in the following equation: and *DS (Data Strobe) from reaching the Amiga until after the rising edge of the S2 phase of the 7.16 MHz CPU clock. This is CPCS = (FC2) & (FCI) & (FCC) & (!A19) & (!A18) accomplished by the flip-flops U8a and USb: inverting *AS & (A17) & (!AI6) from the 020 and using the complementary output with the flip-flop's reset tied to the inverted *AS will delay *AS the de- This generates the *CS (Chip Select) to the 68881. sired amount and terminate *AS2ODLY when the *AS from the 020 terminates. This same technique is used for *DS. This cre- Zen and the Art of Cycle Termination ates the two liming signals *AS2ODLY and *DS2ODLY. (An Asynchronous Synchronous Asynchronicity)

Byte addressability on the 68000 is accomplished by the Up- The generation of the *DSACK I signal from the Amiga *DTACK per Data Strobe (*ups) and the Lower Data Strobe (*LDS). caused me at times to doubt not only my own sanity but that of The 020 has only a single Data Strobe (*Ds). It uses a combi- the universe itself. The *DTACK signal from the Amiga should nation of the two SIZE pins and AO and Al to define the trans- appear and be sampled during the S4 phase of the clock cycle. fer pattern from the 020's internal multiplexer to the external Unfortunately it doesn't quite know that. It responds more or data bus. (Note: bytes appear on data bits 24-31, words appear less correctly when it is talking to internal RAM but when ex- on data bits 16-31). It is therefore necessary for us to create ternal (fast) RAM is accessed, *DTACK comes back almost right *UDS and *LDS. This is accomplished by the following PAL away. Remember that *DTACK is the only way we have of de- equations. Note: The data strobes are not asserted during a Co- termining the length of a cycle. We will cope with this anoma- processor cycle. (CPCS) ly in a moment.

!UDS =(!DS20DLY)&(IAO) & (CPCS) Since the 020 is operating at 16 MHz - i.e., quite asynchronous !LDS =(!DS20DLY) & ( SIZQ & (CPCS) to the Amiga clock - you have to sync up somewhere along the (IDS20DLY) & (!SIZO) & (CPCS) line with the Amiga 7.16 MHz clock. The ideal place to do this (!DS2ODLY) & ( AO ) & (CPCS) is when the two Amiga clocks CI and C3 are in the condition CI high and C3 low. These signals are not available at the pro- The 68000 contains logic to support the 6800 family of prod- cessor and for a long time I had these two lines coming up off ucts, and the Amiga uses this to interface to the 8250s. We the motherboard. However the 7.16 MHz clock that is must also emulate this interface as it is not present on the 020. available at the processor can produce a reasonable facsimile. I A secondary clock called the E clock must be generated. It has divide the 7.16 MHz clock by two using U9a then logically OR a frequency of I/10th the CPU clock and has a duty cycle of it with the original 7.16 MHz clock and this turns out to have 60% low and 40% high. This is done by a decade counter in the same timing as CI high and C3 low (my faith in the uni- PAL U4. When running a 6800 family cycle the Amiga or pe- verse began to rekindle at this point.) ripheral generates a Valid Peripheral Address signal (*vPA). The 68000 then syncs itself with the E clock and issues a Valid In the PAL equations this is DTPRELIM (DTack PRELIMinary). Memory Address (*vMA) and ends the cycle on the falling Now we have a reference point to sync back up with the edge of the E clock. The equation, Amiga.

23 = !QD # In a saner world the combination of *DTACK and the ZI signal QC # (for termination of VPA. VMA cycles) would be sufficient to QB# create the tens SYSDSPREI (system Dsackl PREliminary I), QA; but we have to delay till *DTPRELIM is true to sync up with the Amiga, plus cope with the quick response of *DTACK anomaly on PAL U4 in combination with the equation when talking to fast RAM And sync back up with the 16 MHz IZI.D = (DS2ODLY) & (IZI) # 68020 when we do finally issue a *DSACKI. (DS2ODLY) & (Z3) & (!VMA); Confused? Wait! It gets better asserts *DSACKI in the 9th state of E clock by the generation of the Z1 signal so that the tong VPA, VMA cycle can be termi- Most dynamic memory boards, when connected to the Amiga nated correctly. expansion bus, will assert XRDY to hold off the assertion of

F LâSJ

El Transactor for the AMIGA

*DTAcK while they do a refresh cycle. This puts in enough This solves the quick *DTACK problem. We buffer this (anoth- wait states so that the memory hoard can complete a refresh er 7 ns) by: cycle. The problem is, soon as KRDv is asserted, a 20-30 ns glitch occurs in *DTACK, prompting the 020 to terminate the IBUFOUT =!SYSDSPREI cycle before the data is even thinking about arriving on the bus. The solution is to avoid decoding it till the S4 phase of Add in the Amiga syncronizing term the Amiga 7.16 MHz clock. I delay *AS20DLY again for *DTQUAL and again for *DTQUALI. DTQUAL becomes part of !DTTRIG = (!BUFOUT) & (!DTPRELIM) the *DTACK term and *DTQUALI is wired to QUAL (I needed the 7 ns across the PAL) then QUAI. is added to the *DTACK Now we have an edge which is syncronous to the 7 16 MHz term, giving: Amiga system. We then use this to trigger a Flip-Flop which has patiently been waiting for all this tomfoolery to end, and !SYSDSPREI=!Z!k will ship !SYSDACKI to yet another Flip-Flop to sync it back up (!DTACK)&(!AS20DLY)&0DTQUAL)&0QUAL) to the 16 MHz 020 clock, and then to the awaiting PAL U7 for

misn eo n 113 a' m ôwi ® 9 M N m m6 0 R SIM 12 ran tl A RLI *a EI ~ RN.Mp.R®.W.O N Fil fa 142 912 an 1111111111111111 'xsNNlib * le El q 4091X1 n b tl,1m TT hTTTTTTTTTTTT am.„...- mamma sr es_ 2 â~ Fr a v II ~ ~û 102._ re rri ▪42 e 62 e R-

W W W s e IS S I, E 32 v AO re B re 94 w• A Lie inn LAI 32 102 32 L12 a 12 is x a It

a se a st • m ssr - R 6 é 111 121 19 19 8

014 ~ m or M m 8 m PM 8 ~o •19 W Is 124 amena NIE A ® _NA 16 1 WI 141 Linn v M v ô v A 4-

]o Transactor tor meAMTGA 4 aI additional decoding. I feed the Flip-Flop U9b with *ASDLY so Bus Arbitration that the!SYSDSACKI signal will terminate when *AS does. The Bus arbitration technique is quite similar to the 68000 We're almost done. with one exception. During coprocessor cycles the AS is blocked from the 68000 bus. This gives rise to a possible prob- PAL U7 then Combines *SYSDSACKI with the 68881 *DSACKI, lem. If the 68020 begins a coprocessor cycle with *AS blocked CPDSACKI, and *SRDSACKI (which comes fioul the expansion and responds to an alternate bus master's *BR (Bus Request) connector for future Static RAM), and finally and enthusiasti- with a *BD (Bus Grant), the 68020 will assume the alternate cally begets *DSACKI. bus master will wait for the negation of *AS. Unfortunately, *AS is blocked and therefore already negated. The result is bus What could be simpler? contention. Therefore we must prevent the assertion of *BD until the interface negates *AS. This is done with the equation, *D$ACKo is generated from the 68881 and from the future stat- ic RAM only. !B000= (!B020) & en) & (A520)

19 Ec! ECI9U1.29 9 2 sPRw.n 8 r PR 12 I6RA B2 n cee 4 16 DB 5 2 U6 15 OC 6 U QD 7 PPL 4R31212 U7.17 18 16R6-B2 IQLSIO.n 19 16 BilïN II IQ.PI .enYXr 8 w.et *BQe a 9 w.Ll .R.10 ~ IB U9 on. U1.19 71 • 2 U10 6 .22eB-v a 5

Y6 U9 U11 5V tg 59. Ule 12 13 2 4 13 9 BII U â e WC 12 ~1a9 i2,Xl slrjé0 0 : WC *ORALLY 6 Ffl ~Ie 11 e 3~ 010 5 16R4-B2 91= w.15 7M B s rffiIG .lit ~9' 1116 tn 5v *MOTU in Is te 1 2_- *711991 161 a- 5 N 19 DTFOC• 8

9/• U9 curs ZI 9 h a~ WC 11 n

19 Y6 9!• Pri 3 966 BMe 7 1&0-82 8 .1.14:).. it N U12 220 w9 9l, 9 16 16 8 •94030:1(1 ••.!602011111.6 61EG. QC 2 em HEW uxn Btu U116 SV.

R/ 9

4— —R ~ Transactor win= AMIGA d P@ 1= N; Listing: Equations for the four PAL chips in CUPL format PIN 2 • VRA; PA 3 = A820DLY ; PAITBO 0/ ; PEN 1=a; PYOt Pisalo/ ; MN 5 • A; RV 03 ; Pm 6 =ÇC; DATE Nay 23rd, 1988 ; ?Di 7=OD; D68I®l &ad Fowles ; PmA= MACE ; =TAT wkin ; PIN 9 • BG20; ASSEMBLY Lucas ; PM 12 • MOO ; LOATia v/ ; PIN 13 • BIGO; PIM 11 = 82; /+ PAL1614B2 Pd 15 • aaa2 • /+ PAL DL9101 .SPECIFICATION +1 PID 16 •BAa1; /+ 68020-68881/68000 ANA INTERFACE +/ PIM 17=910; PIN 18=1520; PINI=768; PLN 19 = 1i00 ; PIM 2 • ICPI ; PIM 3=PC1; PIM I=PCO; nafl = (Bank ) 6 I!1SIO0LT II PIN 5=119; Ia.1a2 6 eG20 PIM 6 = Me ; 1 1 I; PIN 7=117; PIN A=116; !WOO = (IRO Is (!u 16 11520I; PIN 9 = WA; PIN 12 • 83 ; PIN 13 • PC20 ; agate = gala : PIN 11 •A; PIN 15 • QC ; !a0a2.D • !EOM ; PIN 16 r QB; PID 17 =Q1; PIN 18• ŒPa; !MD = (!1300 )t PIN 19=E; ( 1320 );

M • (!QD I6 1!Qc )t !vA.D • 1!QD ) 6 (!Qc I & (03)5(01)' 1!9P111 1!® 14 (!Q3 1; (1914 ) 6 19D It 1191u l 5 I 91 I; !aa • UaI )6 {FM 1s UCO I6 1!11916 (!NB )A (1111s (1116 );

!Ta0 = !PClI ; /+ D19CAIPRa: Bpi ABBIIRATIa LOGIC d® VIA MIMATION +/PiIn10 06 ; NN Finelo6 ; REV 03 ; DRE WF 23rd, 1988 ; DESIfCIA Brad Fowles ; !01.0.01; =PAR kakis ; ASSEMBLY Lucas ; !A.0 • 1!P 1 6 I!01 II LOCATION O6 ; 1QaI 6 101 N /+ P1L16R1R *1 I120 1; /+ P11 DLSIA marmite 41 /' 68020-68881 /68000 llRA inane! +/ !Qc.D = 1!ac ) 5 (Th It 1!QC ) 6 110 It eat=16x; IQCI 6 (QRI6 (PA ); PIN 2 = MOW ; ea 3= 13; !OLD = (!Qc 1 & I!QD It Pal = Via ; (!QB ) 6 I QA If ens = 78; ; 6 1!QD I 1!Q1 1; PIN 6 = 0520DLT ; Pn7=7182; /+ PIM 8 = D72C1 ; DB'VaIP32a: DECIDE LWATPA,6800 aka, 1® COPPDCN5.90M SRMCT LgGIC. Pm 9 =190L; +/P15TW 15 ; Pn 12 • DIMS= ; NR FSnaluS ; PIN 13 • ap00T ; HV 01; PDI 11 = D1QA4; OATB NF 23rd, 1988 ; PM 15 • MQALM nSIfiEe &ad Poles ; en 16=u; CORANY wain PIN 19 a DTniG ; ASSEMBLY Lucas ; P1119 = SPMNRI , LOCUM( A ;

/' 211161432 */ !DTPRmA! • I!TI 1 6 1 !7N2 1; P ell DnIA SPecnlaTTa +/ /' 68020-68881 /68000 map ulna= '1 !DSTRIG = 1!MAaM 1 6 I!MPRLMQ ; r H~ ~ ~

Transactor brine AMIGA a !SYSOSPPII = !S1 t Pm 11 = Sf3DSRC11 ; (!DY1C1 ) 1 (!M2D0LY ) L I!0Y00=L) 6 (!QI/AL) ; Pm12= MACRO ; 111.0 = )!D620DLY I i 0E1 I I Pm 13 = SASRCa ; (!DS201111 I i ( E3 ) i (!PA ); PIS 14=DSCA ; Pm 15 n fPDSBm ; !DTT011.D = !AS201/LY ; Pm 16 n ASOOBOP Pm 17 = MOO ; !DYQ0T11.0 = !MOM ; PIN 19= LDS ; Pm19=W9; !WW1 = !SYWSPPSI ; AS00.08 = AIGA : !m00 = IWCS Ii (9S2001Y );

DESCAIPIION: WSFaI DSAQI G®WAYfON mOOBW.a = RISES ; r/PAR19O n ; !ASOOBOF = (CPCS )L ()AS20DLY ); .ID] Fimlu) ; BEV O5 ; 008.01 = BIG38 ; 23rd, 1988 ; DATE Illy !00$ _ 0052011L1 )L (!A0 ) i (CPCS) ; DESIGIS1 Brad Fowles ; COMM Matin ; mS.a=AGA; AS®ALY Wue; !WS = ( 105200LY ) i ( SISI I L (RCS) t 10CASION W ; ( !DS2001Y ) i ()SI10 I L (WCS) t ( !DS20pLY ) i ( 10 ) i (OPCS) ; /A PAL1618B2 *1 /A PAL DnI(8 SPECIFICATION *1 !DSAal = (!SASAa1 )L (!1S200LY It /* 68020-68881 /68000 AAA DRUM _/ (!aDSAOR )L (11S2ODLY )t (!SYWSPAQ)L (11320DLY ) ; PEI 1= MGM ; Pm 2 = D920011 ; !OSAaO = (!SWSIaO )L I!A$20pLY )t PIS 3=10; (!CPDSIaO )L 1!A320DLY PIN 4= MAO ; Pm5=S111; la Pm 6 = WOOLY ; DESCRIPTION: ADDRESS SIM, UPPER AND LOAR DATA Snore A. PIAL DSALR Pm Y= CMS ; MEDMI01 Pm 8 = CPD8Aa0 ; *1 Pm 9 = SIO/S/111 ;

High Quality 2nd Drive for the Amiga •at a price that makes sense! -vesha ~ 1

NE W LOWER PR/CE !

✓ Offers full compatlbil £89.95 with MOO and A1000 Including VAT and delivery V Top quality Citizen drive mechanism ✓ 880K formatted capacity All prices VAT/delivery inc lus ive Next day delivery E5.00 extra. V Very quiet How to order.. V Stimline design lvttetun Ml c,r o g aQC4r{ Phone won ACCESS VISA emae. V Throughport Levi. eeuc.a p da el 63 BRIDGE STREET V Long cable for location some eayerrpncn whenever EVESHAM Callers welcome WORCS. WR11 4SF either side of computer An Subject lo v, 3e.eo.e. V 12 months guarantee TELEX' 333294 FAX' 0386 765351 Tel: (0386) 765500 830 3B

Btu Transactor Ioct* AMIGA ant Programming in M2AMIGA

Translating C source

by Anthony Bryant

Anthony Bryant is a graduate of the University of Manitoba. overview of the structure of the program which proved helpful Ife is a computer engineer working with remote control sys- in adding/changing some routines. tems and robotics, and programs the Amiga in his spare time. The next step was to check the interface with all of the Amiga Both professional programmers and weekend hackers have Library routines; in this case from "Dos" and "Exec." M2 one thing in common, guaranteed to get the juices flowing. doesn't permit procedures that are both function and proper No, not that! I am talking about a new language implementa- procedures. For example, in C you could have: tion. Studying a new language can offer many new insights which can be useful in furthering ones programming art. error=WaitIO(iob) ;/*a function procedure*/ or This article details some of my experiences in adapt- ing/translating C source (all in the public domain) to the waitIO(iob); /* a proper procedure */ MIASMA Development System. error = iob->Request.io_Error;

Since Modula-2 (herein refered to as M2) is a newer language Both examples return the error which has been placed in than C, most of the important support libraries (which am the io_Error field after the WainO has completed. But in M2 the life-blood of Amiga) will be adaptations of the original C latter rase is the only choice. source. Fortunately, M2AMIGA adheres to the C nomenclature in the libraries, simplifying translation. Separate compilation Also, you might find in C: of modules during development along with a fast compiler and linker allowed for speedy translation. dummy - WaitPort(uport);

One of the first library modules I worked on was Rob Peck's while in M2, WaitPort is a proper procedure, so there is no well-known "AudioTools," a comprehensive collection of need of a dummy variable. simple-to-use audio routines that enable the user to queue up sounds (PlayFreq, PlayNote and PlaySamp) and have the au- Flags, operators and constructs dio device play them, sequentially, while your program contin- ues doing what it was doing. Rob sent me his latest version in The representation of flags in M2 is slick, compared to C. Ba- C, Rm FASE 3.0, and I set to work. I soon came to appreciate sic types, SHORmSBT, BrTSET, and LONGSET handle the packing the well commented source (which lives on in the M2 version of flag bits into 8 bits, 16 bits and 32 bits respectively. For ex- - see AudioTools.def and AudioTools.imp). It's important to ample, the IORequest flags are given the name roFlagSet (de- know not just what the code does, but also what the designer fined as a sxogtsET,, i.e., bits 0 to 7) with: had in mind when he wrote it. Rob's source is• also an excel- lent tutorial on using IORequests with devices. quick = IOF1agSet(0); i.e. bit 0 is set noWait = IOF1agSetl61; i.e. bit 6 is set Required adjustments The + and - operators then am used to set or clear flags. M2 Since M2AM IGA's compiler produces code in one pass, all ref- really has none of C's bitwise operators and none are needed. erenced objects must already be known. If a procedure is to be You can easily check to see if bits are seta clear. In addition, called whose declaration is further down the program, the pro- you can define your own SETS as subsets of the basic types. cedure must be FORWARD declared. (FORWARD is a reserved word). I opted, instead, to re-order all of the procedures so that M2 has a nice selection of looping statements to chose from. this wasn't necessary, and in the process of jotting down all of Decisions, decisions! In C, the 'for' looping construct is really the procedures called by other procedures, I gained an a variation on the basic 'while' construct In adapting from C, e H ~~ •~ Transactor wm.AMIGA a D a[

I have found that, in most cases if the `for' index variable from generating chunks of code; that check subrange and array post-inerements or decrements, I would chose M2's FOR state- indexing; overflow and underflow; division by zero; stack ment, but if the 'for' index variable pre-increments or decre- overflow check; and mow....) ments, I would use M2's Wimp statement. C's 'do .. while' be- canes M2's REPEAT .. t1NDi., but don't forget to reverse the M2AMIGA defines ADDRESS as a pointer to a BYTE. logic of the 'while' expression! The one use of a 'gour' in AudioTools was easily handled by M2's LOOP and par combi- TYPE nation. ADDRESS = POINTER TO BYTE;

String operations ADDRESS is type-compatible with LONGINT, so that when you de-inference an ADDRESS you are looking at a BYTE, and when M2's definition of strings is slightly different from C's. If you you INCrement or Decrement an ADDRRCS, it is by the BYTE. want to pass a string parameter to an Amiga Library routine, that string must have a terminating null character. (In M2 ei- But in C, you can have (BYTE *) and (woRD *), both address- ther OC or "".) But a variable defined in M2, say as: es, but what a difference! Without exception, you can trans- late (BYTE *) as ADDRESS, and ARRAYS OF BYTE are used in VAR preserving audio waveform data in AudioTools.

string: ARRAY [0..11] OF CHAR; The use of (woRD *) is more complex, since it is usually ac- could be filled completely with 12 chars and no null char. (If companied by the indexing [} of an address. The indexing is less than 12 then, of course, there will be a terminating null.) by the WORD. C goes along with this, hoping that the C pro- A special feature of the M2AMIGA compiler assures that all grammer knows what he is doing! (Indexing an address, in- constant strings, stored in the constant space in a program, are deed!) In M2, you can pass open ARRAYS OF WORD, which is properly terminated by a null. Thus: really what we are dealing with in this case, between proce- dures. The use of open ARRAYS greatly simplifies this task (and OpenDevice (ADR("audio . device") , in sorting out pointers-to-pointers). The actual ARRAY is not duplicated, as this would obviously consume more space; in- OR if CONST audioNatne="audio.device" then stead, only its address and length are passed, ensuring the in- OpenDevice(ADR(audioName), tegrity of the data.

works equally well. M2's strict type-checking forces you to think about what you are doing and about the results of your actions; rather than M2AMIGA provides the requisite procedures for string manipu- leaving it up to the compiler to figure out what you meant. It lation - Compare°, InsertO, Delete°, Occurs°, etc - handling clears away all (well, most) of the cobwebs and you are far string assignments with ease. less likely to be bitten by a hidden bug later on.

Numeric operations and addresses Most of the adaptation work, though, was minor editing; i.e., changing '1*' and '*/' to `*' and '*', changing '=' to ':=' and Numeric constants, likewise, are handled with ease. All con- _' to '=', changing 41=' to 'it' (I like # better than o), and stants, being untyped, are converted (coerced) into the type re- changing '->' to ‘Al. M2 has special commands, INC and DEC, quired by the library routine. to replace 4+', '+=', = and '-='. CSt1arr handles '«' and '»', MOD iS "9d, NOT is 'l', AND is '0.W', OR is `!l'. (It recalls Integer arithmetic is another area where slight differences ex- to mind EASY C May 1986 BYTE magazine!) Done! (Well, al- ist. Rob's routines for calculating note duration and cycles al- most...) ready maximize precision while taking care not to overflow a 32-bit word. In M2, an unsigned short is called a CARDINAL The feature I missed most is C's compiler directive, #define, while an unsigned long is called a LONGCARD. Because of which, besides defining constants, is very often used to replace M2's strict type-checking, it's happiest when multiplying or entire procedures, both function and proper. In AudioTools, dividing the same types. It won't let you multiply a signed in- this technique is used effectively to add all of the Channel teger, INTEGER or LONGINT, by an unsigned type. If you know commands, which are all defined in terms of the basic Con- (or suspect) that the product of two CARDINALS is going to be a trolChannel° command. No choice here but to write out many LONccARD (very likely!) you are best to do a type conversion. very short procedures. (M2AMIGA does type conversions rather than type transfers [M2 lingo] since this is more secure. If you don't, M2AMIGA's The AudioTools module (on disk) has the appearance and mn-time system will alert you to an "Overflow" error!) function of any other library module; consisting of a symbol Ede (sym/AudioTools.sym) which the compiler uses, and an (As an aside: Once you've finished debugging, you can switch object file (obj/AudioTools.obj) which the linker uses. One of off the run-time system checking. This stops the compiler the reasons M2AMIGA compiles and links as fast as it does is

4-I letl HF]- ❑ Da Transactor n the AMIGA a t these "pre compiled" modules. All of the symbol files needed And finally, the code generated to produce the executable - are brought into RAM during compilation, and all of the object AudioDemo - is as compact as that of Manx C, though it con- files needed are likewise brought into RAM during linking. tains extra stuff (Terminal window, etc).

The test program, AudioDemo.mod, is a simple example AudioTools makes a nice addition to anyone's library, whether which 1MPOR7s all of the procedures FROM AudioTools. In or- in C or M2 and thanks to Rob's source, I teamed a lot about der to have some waveforms to play, I fust set up some wave working directly with Amiga devices. arrays - sawtooth, triangle, and square. Although M2AMIGA has extensive math libraries in RRA! s, LONGREAI9, hanscen- Having a PlaySamp and PlayNote in my library, I turned my dentals and EEE double precision transcendentals, I chose gaze to a ReadSamp and a ReadSmus, to be found in the IPF M2AMIGA's special fast floating point type, FFP, and simulated specification ssvx and sMUS. But that's a whole other story my sines and cosines. Conversion of PEP to INTEGER (and vice- (and a much larger library). versa) is simple enough and voila - a sinewave army. (I also tested these in AmigaBasic - obtaining a plot to see that the start of the waveform equalled the end of the waveform, some- OEIBIfi01 x0002 AodlMals; what important in linking audio data waves to avoid clicks and MD ON IOOI01039 vodka 9LBBcr.3.0 by lob Back other noise.) (AudioTools expands the basic 256 byte array to achieve higher frequencies and these waves are linked end-to- /his software is in the public &.do end - see SetWavep in AudioTools.imp.) xLmiga Module-2 adaptation by Anthony Bryant *1 The use of M2AMIGA's Terminal library module greatly simpli- FBm 51sm1 ➢@(BS DORM, BYE; fies a short test program like this. As M2AMIGA supports both FM Audio IIRERT cu and Workbench, Terminal automatically opens up a win- beaChaMsis; dow (if called from Workbench) on which to write strings (or Prom rra Me Byte, ISJguest, lessees, Wgiortltr; write decimal or hex numbers). M2AMIGA's run-time system hides some of the grunt work from the programmer by execut- S ing startup, automatically opening and closing Amiga libraries, mdom- =20;anuale; audBuff = 20: (* amber of mob mg packets before need to allot t) and passing cu or WB args. (This is a liability if you abso- 'added = 3519515; lutely need a non-standard AStartup.) It error muta mayas *1 bdmmoelnalaotad = -1; it Soul B at of Laya t) mtrma(amal = -2; it ut cad by your task *) M2AMIGA's Arts library module forms the basis of all programs wtOaYmry = -3; (a adret retro fro LLlatllm t) and is integrated with its other library modules. (Not Amiga runs Library modules). When run-time errors occur during develop- latlœ*JLOPD ment, they do not go the way of the guru. Instead, the program request: ICPagmst; is interrupted with an AutoRequester which reports the cause ellfMey: IRAI; data: /311.53: of the error and leads to the freeing up of all allocated re- laya: Mar; sources that it knows about through its other library modules period: 990]11; (by the use of a Ter mProcedure0, see below). For example, alum: 990T/1; cycles; 96II24; aborting after the error requester closes the Terminal window ultaWg: *wage; (t op to here, sr as genii* t) (if open), the FrkSystem module closes all open files, the identifier: 13019, (t This field is added t) Heap module deallocates all previously allocated memory, etc. UP; BrtIœPtr4;OT39 10 WEB; The Arts module contains several interesting procedures, such PRx9O9laiadtoll: asg4odtPtt; as BreakPointO, which causes a (temporary) program inter- PAOC90RE aacklfDom(1: 13OE9; rupt, and DebugProcedureO which calls (installs) a debugger PROUD= noisWodko(oport: 115¢ort9tr): (not supplied) following a program crash or interrupt. You can PyOCEOBB ut®muk(aamt: I46I11): 1gIBl*1, even add information to be displayed in the error requester or PBM®OB8 hMhmoellrLamel: 1WOIQ1: L0*01317; design your own debugger using information about the Ma= Otop2md(riemel: MGM): tm9l; croshfmterrpt stated in Arts very own variable, errorFrame. PAOC9WH stadramml(cimml: MGM): Mat Pf6®OR ltoeb2mvel(tlimul: LOBgIRk): 101611l; P6CW9 Baseaaamei!amul: 106E!): 111111117; Of course, you don't have to use any of it (nobody is twisting P1OCJ0m8 Iethealycbm (channel: 30611r): a*BEb your arm) and so, since AudioTools uses mainly the Amiga Li- brary modules, I decided to use only Arts' TeèrmProcedureo to P6®OP6 WyfetJoG(vport: WgPonptr; flag: 1639*): 1m3R; do my own cleanup - that is to call FinishAudioo. TermProce- p6C®NY Bet6w(ckeuel: 14163k: durep functions at the end of the program and in case of error 9E mention: MIS Q BYE): 1011011; PAm698 det9aeplrAeml: IASEP; (and, after debugging, could really be removed - just don't for- 16 smpimdio: /00955; get to call FinishAudiop!). This avoids the need to reset length: Ulan : 106Ef; Amiga, after each debugging session! P9a90PB dHPP(aeaoel: MEP; Arid, who: C90191): MEN; 4-i 4fr TR Transactor foru.AMIGA La ❑t PAOcEWPS Playlets(chmel: MGM; p~ note: 0731111.; (t specific note 0 95 ) anydeu: OUT la sassas-11 a Oeyte: It chant masks for nano •) wino: (271111; (e volae 0-61 t) I &oration: CBDIUL; (t 1000th, of a second t] dynamites: BARS; (t 'dynamic' Ia', •) priority: Byte; (t precedwce value -128 to 127 t) glabaliaam: IIBSS: (t `global' ( really "static") Ion's t) sessageport: IlegPoratr: (t for une by egceaota() t) id: BIGm); le Pad waveform buffer contains S octaves of the covt tl PHOC®OPt PlayTrq(daunel: Lc GTT: frog: (1BOIIB; It specific frequency 281z to 7000112 t) voff eats: IBIT (G..0] R PIPan11; (t tare mvet0m for that octave begin.*) calme: CERDIBAL; It calme 041 t) ales: BRUT (0..8] s CUBDIL; 1• length of each wavefom within a buffer t) duration: CPDnf: (t 1000tis of a second t) penal: ABM (0..12) s =M AL; (t Period of thew notes within an octave t) priority: Byte; (t precedence value -118 to 127 t) awsgeport: aglortPtz; It for use by Ilaykaote() t) 1d: MGMTI; PBm9PJ PlaySmpldael: 1a01R; internal procedures ______t) period: CIRD311: It specific period value 127 to 500 t) calme: 071111; It vola 0-64 tl le Psnln - free a global (really static) or a dymalc, allocated Im t) duration: CARBIIIL; (t 1000tbs of a second 1 priority: Byte; It precedence value -120 to 127 el PWOBOB PrwIa(fob: Ixt10117r; channel: 1/41G])12); sessageport: Isgportptr: (t for une by Ap%sot.° t) VAR id: 177I7); 1: =WS; ssn OD Ldidtoola.def II (iob^.rgowt.nsaga.noda.na=dysaddal T®I PrWlatliob, slsliob"I)7 n (dyoairldanwll t 0) MIN Osldynamixlda.11l; It subtract one if nonzero t) 171,710717 011 B ! ludioTcols; OD; BLS" Ilob".reguant.snaage.node.na = global/keel i® USE a /771001.5 version IPafSI.3.0 by Rob Peck 1:= lob•.rqoese.raasage.lenqti: TY Il < mdNffen) 7a0 This software is In the public damto lnuae111rn PI496: (• frees the one for reuse •) aD; 11217ga Ie473-2 .daptatlon By lathery Bryant BID; q PB PIMIm; na MEW 1772 1007.7,711,11711, L01177; AWogloylo - look at ALL of the reply ports and if any toes nlR Indio fl hanging around vit nothing to do, then free that. free, patrol, allocate, (t loan tends •) parvo), ',merle, =Wait, mltilessge, (t Mkt flags t) Judie may still be playing the mefos as we get a hest :Ortho; through WyGetlote. DaySetWote marks the fob message block as free-able, sal Dec DPad Idem it find, that the identifier field is set to zero) but we have Delay; to have a way of zecita]at og in this list of rosages. PM see DM lnvalid,reset,read,crit.,update,cleu,stop,start,flush, It Iomdio ole t) In other words, if metlog le free-able, free it, otherwise leave it Viet, It IB- flags t) on the list. So rather than amvlq things hat the front of the list, 177907, hinge, IagPortltr, Rode, TmkItr, flattish, DevlaPtr, lets just Alk through the resat* list, rww (decode) that Is Byte, Byte, aWgs, WeBgSet, Useable and leave the rest tore to look at the not tine. ll1eJ4ar CloiBevie, Tidiest, fruit, %tag, ° aOevic% Pntaq, shin, ReltPort; PWI Bm6upport WOW PROP! Reaployralll; BgidO, cr ateP d, DaletePort; TAR 1: a m: ag%rtPtr; CORSE lob: ExtIalptr; AveSize-512; It byte aise of allocated story for Ave OST t) pushback: Bxtt®Ptr;

TTB ( 70at happens here is that lob's are reroved free the message port aSlsg#dCOAU ten they coo back fm the audio device. If TW have wt the msage: Message; sessageport nonzero, it mans that you wanted to to tuun identifier: tAGnT; (t ratdee the bottom of atim t) this note began to play. The Whalen part of the fob is then 17; linked, as a snege, onto pour user port. So this routine avagPtr301/52 TO aWsg; cannot free the lob until it is certain that TW have finished using it. The lob Priority f laid a PMD here. If It still VIR nonzero, the lob 1s pushed back onto the snug. port (on the mit: ABR 10.,amrChan-11 a OnitPtr: It global pointers to units t) end of the essage queue) to be read again. Is hold a polder key: eaux 10..than-11 B arum (• global value for Woe baya •) Eared °puobbed° that lets us keep track of den we see that usertask: WI! 10..m6han-1] Of Twntr: (• user oleos Wal channels t) again. T1 ve see it twice, it wean, we ban osgeed a full (t 1n preparation for raking this a shared library (loadable from disk) t) circle through the game of sewage. and have freed everything that we can this time. Therefore, we .mine it and either openla: 101udio: It 10B to open and dose the device t) free it or push it bank again, then exit. device: Devlaptr; (t global pointer to adio device t) controllort: agportltr: (t Port fox Cmtrol(amal functions t) Bsn touffu: IBR 10..mdluffma-1) W maw It global, static beam t) Pa i:4 20 mztan-1 BY 1 CO lose: ABR 10..aud3uffen-11 or 11e01711; (u keep teck of .etlm used t) (t raw all lob's Iron ILL ports, unless we have to posh on back •) dipaudio: BIst f0..mcan-11 W BOWS; (t pmts to Aveu in 717 Rie el np:= replyPort[1]; datalwgti: Ron! I0. than-1] 7 Tamm; (t length of data 1n MD RAI e) replyport: 181T (O..raaxan-11 Of afloltltr; (t me ReplyPmt pu ta t) pushback: Ill; (e aching Wiled hack 10 fu •) drat: AMY 10 maman-11 or inapt ( keep tuck of eyelet s mad t) H

Transactor toc uw AMIGA 4 a[

Ithw Extlata(Ostwglapll; • like a lousy idea, unless it is acoo@anid by a variable BYia (lob t 1m) DO • statics today that dictants to zero da dl statics (t Tint a if asapport in urban is not m; t) t are done. Eat makes it u,d easier to deck than going (t if so, ado device is done, ht um has not acknowledged t) • through all of the inu ai]'.. aayb not. (t this message yet (by using !hymaote). *I II (lth".wxitWg.rnlyfort i III) TEE KR 1.4 10 wrt'han-1 ET 1 DO Puftg(gr, lob): IT (dpafrli) > 0) TM II ((hob pndbadl E o (pasha = EL)) T I It If his charnel still playing a t) p := lob: (* a=mber 1331 one pushed back t) (t dynamically allocated block, wait *) ®; It for all messages to return before t) aha (t W prop= exits. t) rrwla(iob,i); (* aeapport is lII, can free the lob I xemployla0: (t take another shot at freeing it all t) EEO; ED; ion. Et1c tx(ameg(T)); ED; RID; IID; FOR lid D0 wtaan-1 BY 1 DO It Check again as we pearly =it t) ® aemployla; II *midi] = (I) IRE IIC(aatas» ea; KIM; (*PAM - allocate en la , global (really static) or dpWe fee un. t) II (statue =1) tea (t all dynodes are free, now deck the statics *) KR 1:=0 10 mdBoffes-1 BY 1 DO PPOCBBE aetla(dmenet: 1AIDO[): crtlaptx; II (Iamll] = Tas) E® RUDE Tin; ea; (t aine not free t) NOR KID; 1, uwreply: CBMB1; Byes Tas; (t BOB! t) lob: mtlaptr: (* In cave we need to allocate one t) ESE Bgn RIM This; (t still ewe out there! t) mopluyla(1: (* find already used was and free hoe t) IB; ® ChedlOIDae; II (dame(_ -1) MI useraly 0; USE usereply:= chained; ea; (t - USE support prooed:res --- t) (t try to allocate a global lordly static) Sob to an t) Ea 1:4 g0 eodBuffers-1 al 1 DO (t laltkudio return, °port, a pointer te a message port at did your task II (knell] = yiSE) Eea • receives a message Sn a pattlalar note ERIE to play. (t ve have our global (really static), so mein parateis t) • You dort man this value noeuhere, and use it to call !elation inueelll:= IBE; t or Tleisiudio. YayGetaota is tb oar of tke routine that pu call audbvffernreguet.device:= dmlw; • to died if a note has begun to play. audhdfer Iii •ngaest.amp.zeplycort:= Miff ortluserap1yl; * If an error occurs (can't Opendevice or Cre t.Portsl then pointer = m aidsuffaffl.rgwut.aope.length:=1: *) audaaa(il.regoest.aeage.orde.na:= glddpa: EKE ha(adddfer(i)l; PROCESS yoiGdlo () : IegportPta; ED; WAR ®; e¢ot,t: LONGER; fintuser: EDIISa, ( TES WILL GE IDOID den shared library is zeds *1 It if all global. (really statics) an la °waxy to allocate diuretic one t) eaII iob:= ntlœpfr(hrrocl a(0IB(lob"1, IregS=timecfap) ): fhut°ea:= TER; II (lob = m) lea Rana In; ea: (t out of emery t) (t we bave cur dynamic, so assign paraders t) KR 1:4 10 audBuffaa-1 BY 1 DO lob*.wguest.dadce:= device; b usdil FALSE; (* declare all asap blocks are available t) kd".rgwat.aeage.replyPort replyPortbeenplyl; lID; fob".reguest.aeage.node.oa:= dyaitlmn: Sob".regwsuaweage.lagth:= dpairlueaplll; opmla.kagth:= 0; (t Open devin but Ain't allocate channels t) leldyWxlusergl/)); It add one to amber allocated to a channel s) OpeoDevice (ER adfo.devdca•), O,kalapwlal .IaDa10)1; REM lob; (t returns error in to Error field; should be 0 el ED fetid; error:= laOII((opeold.regoest.errox); (t EOmamllt -1 t) II (error 1 0) TER PEW m; ea: device:= openla.regueat.device (t get the device address f later use t) (t awklabw - to a if all fob's are finished (i.e. freed up) • if PPE tin entyWng IS finished. KR 1.4 TO nxGa-1 BY 1 DO t) replyPort111:= Crutaort(0,0): (t Parts for rePlfa from ath Chanel I II (nplyPort(l] = m) Eel giea Ill: MID; PEE= Chwkl®one(1: loam; oa thlpmdtoli):= 0; (* hove not yet created the aatlaaples t) 1, rtadu: ElaIDIR: datalengthlkl:= 0; (t length of waveisngle data in fl UK t) Nall dynalrltl:= 0; (t no dynamic I/O blocks allocated t) stated= 0: (t an than are still ea ith'a in prep t) (• An status = 4, tbn antra* Is free t) (t ma loplawtd as a shared library, Ylxetuet will only t) (* be TER dao the libraxy is first opal. M ER 1:4 A Snuffers-1E 1 DO II (izew(i) = Bn) Eff II ((irate= = TEE) TEE (t Sooner or later, this will catch both keylll:= 0; (t bit by values t) t the statim and dynamics. lote that unttlll:= BL; (t Mt unit gala •I t this will only work if ID (PEPB: 110) nwrtaskll]:= m: (g no channel owed by ay task t) t fob's sent off with a dotion value PID; • of •0•, became zero ens 'forever' W;

Eampl%I031): wntxolPax4 CratePort(0, I); (t use for control a syoamoos function t) ED; IF (rnotxolport = m) TER BSUB m; ®; MID; (*Note to Wlavt=n... maintaining month] now sees (* Idt anychn earn for use by etaaael t) -19—

Transactor teethe AMIGA I4 at soya/m[07:4; anydso(1):4; anychanl21:4; aoydeo[3]:3; en; (t bit melon buffer offsets MIT for uee by Flagon t) onitichanmaj:= iob".regoert.nolt; wffrtsi01:4: voffsateil1:ab56a voffsata121:49/; wffsets131:418; keyltarml:= tab".allocny; nffaatel/1:480; wffsetal51:496; 'Aisne 161:n04; 'offset/1J1:408; usertaskltenvuel:= FlndTask(0); (t IS user task mate it ton t) wffaate(8]:c510; (t bit length of each wanton In a Mier MET t) MIP8 ch=ue: (t valid channel mbar (0-3) +l vlenl01:456; vlao111ï 118; alanl2j:41; vlenl31:=32; v1m111:=16; ® Gttamnl; v1eo151:4 ; vlen161:4; vlm131:4; v1w181:ü; It bit period value to go vith nota within an octave t) panall01:420: pena1111:401: puval121:=381; pave1131:460; Use Iapetiflhno to determine If you (still) ow a particular chmul. pmll/]:=339: pe[val15]:s320; parn1161:=302; pernl131:4e5; The radio din bas an amogrent by gbh a higher priority ragout perva1181:469; perval191:451; prsn1110]:QI0; parvel1111:426; for a Jamal than the one that already own it t be made. The higher prvnl(121:41/; priority request can actually ansa a charnel to be stolen Ma a alar. dyowta.a:= l31(•dyanafe); This feature say be lepi=vted in a future version of mAotaol., globale= := aDR('g»'1; (ibexes library version), in tin, depending on the tasks mming priority itself, a higher priority teak mild soma aC Getfienml 31Tm Cnataeort(0,0); (t m user port +) for a channel that is already omd by another task. ® Initiate; MUM IethdYfheo(dmnel: 1MCpT): =GM; Sam v1Qport procedures t) UGH II ((channel < 0) ® (channel > aact4en-1)) 1111111 IMP! (bdCiamelsdexdl: (+ Gt(5aast: To regent "are ohmwl, use channel = -1: nm (ueertarklchamell i yldTask(0)) T=af® IootYomfbamell: ®: t To request a specific Mond, me rat = 0, 1, 2 or 3; pTU31 0; (+ If Y00 still ova the chiming +) t Again IDP, this retotes tw global. an well es the channel outer! 31D L'Aatyptban;

PGC31ORE Getmamel(chanoel: Idasm): 101612; (t - —_— interned procedure use only — +) Op error, damn: 11A6m; PflEDt Con troilûmul(cannel: WIGHT; amend: CIRDIDL): 1gCm: atm v a gLL led: MICIetr; error: I0y6an; contEolIOB: Inn; fict3CEPtr; BEGIN cmtrolICE:ll%: RIT®; big= 1311=troll011); el ca lob".request.dMce:= device; IT r Iatb0) T4) lID (nand

K 16s1 ~~fl'

D= I I 7ranadar w m. AM/CA 0 a

W tgrtt":=avdom(j); EC(tpt); p address II error: LCiGE!. J:= J a rate; MII 01114 J > 255; error:: CmtrolBLamellrieoeel, free); rate:: rate * 2; II (ever i 0) Ti!! PROM error; UM; B®; usrttmeklcaaelj:= W: C frne again... t) EMI 0; (t O.K. +I RIM 0; (t everything o.k t) ED ataen; M PreMlaoeel: (t SetMap crabs Cab PE, if sec scary (only once per channel) (+ ChrkiBone to sa if everything is finished MPS calling PlekeLlvdlo t) • unless •lagth"= 0 Airs jut frees up existing .ample CM PAY or... ies byte byte users supplied audlo* to CM RAX, PPOCME Berhlfamne ll : 900LW ; • unless `aw Wu o 0tti ch just autaCMn PE (without copying) BB6E • and returns new •emplavdio' to user, (until if maples laded fro disk) MORN Chectl®Dowl); + Pots euh element in •saplmdlo' seat be in the range -128 to 127 since PBD ChellfDom: • audio M retriever one word (15 bits) at a time and reads two bytes t) C Set Period and Velma of a vote that is playing. t) PaO®OE Relay (channel: 1Qe9}, Paons atPvldanel: itstre ; Period, alma: nil); LBGIR; W supleanda: EDPES; (t returns new address t) W length: LBG111):Imi6II1; error: IBG1f; Vitt ab: LrtIOPPer; error: aLa6IIP; umBolIB: atiœ; j: LMEl; BIM chlPtr, saapt[: MESS: (t *ere 126E9 = POQR 10 WS t) error:= 0) chou lebsonell; ia1P II (errorr 1 0) 4M MOH error; M; error= 300ha6yBenlchanell; II (error i o) S® E4OE error: ml: ith:= IDR(mntro110B); ah".reguest.devdce:= device; II (chlpaudio(channel) i 0) tie flies up old ma t ) 1m".reguestassage.replyPort:= neatmlPort: Pnaamloapandalthanell, datalmgthlchamafll: fob".regvesLalt= m8 lciamall; rupadto(tiamll:= O; dwlaogthlchmml):= o; lob".ellocle1:= keylobanoell: M; II (length = 0) ?M toPAM 0: AD: It test fret p old zee t) lob".period:= period; (+ nee period •) II Ninth > 131012) MI length 131072; M; It licit length t) ab".volue:= volute; (• new aloe *) II (chipudiol ll = 0) ?ii (t only allocate ace per cannel! •) lab".reguest.cmmod:= pervol; (t ADM PBBA1 •) thipadalthaenell= hllodrllmgtb, WaBsgS+t(tifp, alleLul: lab".regoeet. flags:= quick i perm); CIC, QOM 11DWEg01 t) II (chipadioluhemell = 0) tut !EOE (etCEaory); M; Bpin10(ith); C This one till be apmMenous; tie dataleogthlchmmll:= length: 1+ for use by rues +l (* affects whatever is playing on this channel at this time. t) M; ilaft10(ab); (t B to wit, since it w111 return •) II (sapleavdlo = 0) THE s. luudio a àlpmdiolohmmll; tutu 0; ®: error:= l6GEfliob".negoest.ernr); (l IDIOM 110A11Q! Q -10 •) 11111912 error; (* error in ko_Mar field; should be 0 t) C ok so far, length and seepleaudio nonzero, non copy ton 861 tj M ate!; drip[[: thipadiolohmell; saptr= sapleudio; (• Shave creates CM Pi, if nncasuty lady once per channel) iB j:=1 10 length BI 1 00 • and copies to OM PIN (with expand ave) users MEA! (0..2551 Cl MI, thiptr*:= senate; EClchiPtr); EC(smptr); l* inset address t) • when eachelmnt in ME past lata range -MI to 121 since M; + audio M retrieves one *ad (16 hits) at a tine sad reds two bytes EAE 0; (+ 0.a. t) ) M SetSpap; PPQEOE Setave(chanoal: 1602; M waveform: 11711 Q BM): 1011OIIf; C _—__ internal procedure use only ---_—•I W error: 16®f; PPBIDM PlarM(cannel: 16011!; 1, j, rete: CED3EL: dPtr 1Q03S; (• pointer to waefow in CM W t) tptr: MUSS; (t stare BDDp6E = P011112 A BYE *) le: LQ9MD: BIM per: ChmUAL; error= IafhatByBa(camel); al: CEDIIIL; II (error 1 01 ?M ;MI error; M: cycles: CAROM: priority: Byte; II (thipadio(thaoell 1 0) MI (* not first time t) mesugeport: wyottptr. II (databogthlthamell i aveae) Ti!! (• oat be muga t) id: MGM): 1.011011; FrS (tipaudiolthanvell, datalmgthtmavodj); W chlpaudloltbavmlj:= 0; datal•ngthlmavmlj= 0; error: LOWOIE: ®; lab: BrtIMtr; PID; Ma II (chipadiola&ameij = 0) MI (t only allocate if tee slay! tie iab= atIBlchamell; thipedalthanelnnel) = 0) THE Ria, Bout0fl atlrhip, atleull; II (lobi IM) f W (t rat the ?arresters •) IP (alpadlo (slim)! = 0) THE RUM (mty!!mry): M: icb".rgnest.vdt= udtithaeveq: Atalegthlclneell:t wangler; (1 for use by hseRa t) 60b".111odep:= lylclmel]: W; le".data:= wiptr; It ok so fa, now copy array to CHIP ➢E (with expand mew) t) ith".lmgth:= le; tpb:= ;hipmilo [channel); im".palod:= per; raa:=1; Sob".vobaa:= vol; IB1:=0 A81!100 fob".cycles = cycles; j:= 0; lob".rgoeat.meoage.nade.pri= priority; PIDW (t replicate aven in decreasing sapa aises tj ab".ldentifien:= id; (t for apport of tell--then-note-state t)

H lf• Transactor lathe AMIGA 4 ❑ I lat".requnt.wmand:= write; (• OW Win *I dch".rguest.flags:= panni; (• IOW/ PIDw1 tl PNC6mPY Playlrglthenel: 1016IIt; (• specify channel onto 0-3 t) frog: 011.011111; (• specify scalar frog 21-7000 b •) 1• Initialize usage port. If 111, thn no pushily back of a snag.. yobs: CADIa1; (t volume 0-61 1 • If omen, message gets realrmlated by Pdgloyio water durance: CIDDIDL: (• 1000ths of a second •) • the user finally acknowledges it by using WyGtlote. •) priority: Byte; I• force a age -128 to 127.1 mseagepost: WgPort2tr; (* for use by Ignition t) fab".vxltelhg•xplyPort:= mmagegort; id: 1AKffi); II (mnmAport t 111) 0® PI! (* 'apte to this nonage - 1DIa WS>YIDB16B •) error: ILg®7; 1mb".ngmt.flags:= iob".xgmt.flage • writtlWnge: period, octave: CIBDm1; ®; Spurt, Inert: WOWS; Begialo(Sabl: length: a 861018 0; I. all vent ok •) waaepniater: IDmA9; (• where to find start of waveform t) ®: cycles: CIIDID1; fl (cutOBlmory); (t (else-part) in me :no, couldn't do the show +1 1: =DM; ED Plagffi; accept: B001BIY; non (t PlayMR° - starts a sand m the channel with specified period and wham. error:: Ietnap*Ban(dmell; • This nice little rutin takes a note and plays it ea the given II (error 101 Sia 11A11; UM; • vola. The note is basically an Integer fm • 0 to 11 (c to b) plus 12 per octave above the first and lowest, II (face = 0) 2® B820a; BID; • whirs yields a note range of O to 95. II (volts > 61) !00 voice 64; OD; • The waveform tom is detemoed by eddlg an index (*offsets ll) • dependant on the octave to waveform in chfpadiolchou•11 as setup by 5:= 0; (t see if we CBI repnenot this frequency, If not, reject it t) *Beane. ibe length of the wagon (iv 1,1of ) is likewise dependent IADP It figure out which wisdom to m... 1 * on the ancon. Dote that octaves start with ten, not one. octan: 1; (• start with the first elan value bemuse t) t the period and volts can be modified later, using GtPP. aazpt:= PEA; (• we not to use the longest waveform we can. •) t) period:= IMM. PD(audclock) DIV I1496021D(fIeq) * (wlecloctsvel ); II (parted > 500) UM In; eco: It frog less than 21&. •) P90®ad Playbte(nanel: 10116017; It specify newel muter 0-3 1 IP (period > 121) t® ampt:= ADB; @f; KID; note: CIBDIIIL; (t specify me oohs 045 t) 1:=1+1; II Il > BI fill )1417; Bus®; solar; 0AIa6; (• volts 0-61 t) BID; Motion: Ci2DIIID; (t duration 1000th of a sec. t) II (accept = IM SB) AD 11.87O11: ns; t reject it t) priority: Byte; (t fora a range -128 to 127 tl msgport: MsgPortPtr; IT (tpaudfoltamll = 0) ABB BBfuPB; ®; I• no SetBave or $etbp I!t) Id: IAI6I17); vavepointer:= chipaudio(cheoell + IWflSS(woffwts(oeteve)); VII length:: vlw(ocovel; error: 1Lersin1; period. octave: MOM; It divide dentin into two parts - inert a ]part - for calmlrtlow t) Spark, ]pmt: CYOID1; II (duration > 1000) ABD apart. duration DIV 1000; USE ipart:4; KID; length: 1D16OID; jpartn duration - (inert • 1000); wanpointez: MUSS; (t who to find start of waveform tl cycles: CYOm1: (t fool it a little so we don't gat integer overflow— BEM (• 3.5 zillion tires 1000 is about all n can take in a 32 bit word •) arm:= Ieftaayam(chmnell: II (error 1 0) 7®112012; YID: cycles:: IwaGaRu(frq) • !part) + IIAImkA(freg) t jpaxt) DIV 1000; II ((cycles = 0) /SD (duration t 0)) ter cycles:: 1; CID; If (note > 95) t® note:= 95; NO; II Koine > 641 MS whts:41: ®; error := Play78II(chanal, nvpokter, length, period,volume,cycles, octave:= note DIP 12: priority,eessageport, id); MIRA (• just ignore error 1 II (Atp=owb(chma11 = 0) 2Ba sorrow Zr, ( Goa Gump i ll) aD Playtrq; nvepoknr dipandiolmhannel] SDI= (wfisets [octave)); length:= vinfoctavel; petled:= penallnote WE 12); BayGetlote - is used to synchronize the Play audio routines, using aengeport and id, (parameters of the Play :onion). (t divide duration Into two pmts - inert r jpart - for calculations •I where uport Is the pointer to the port you received from Initdudto. IT (duration > 1000) EN ipartn duration DIV 1000; Bab ipart:4; KID; ]pmt:= duration - (!pert t 1000); dm flag = FILS!, the routine return immediately, with an id = 0 (no id available), or the value of the first id to arrive at the port. (• fool it a little so we don't get integer overflow... t) (t 3.5 (million tins 1000 is about all se can tab in a 32 bit word t) who flag = AOE, the routine will nit if (end only II) there is no id. In other words, you can cause your task to go to sleep until the cycles:= ((miœnDlecdelack) t ipart)+(1411010(mdc10 k) • jean) DIV 1000) nest note begins to play. you decide what to o fora specific note. DII (1amhID(iength) • period); IT ((cycle. = 0) MID (dentin t 0)) Aa cyel...:= 1; KD; OOAw - if there are no sexe notes with tressageport nonzero in the gam and you specify 1101 for tie flag, you can mue your ezrer:= Playlet(claonel,nnpeoter,length,perld,wLu,cycLe, task to sleep forever!! p riority, sngport,id); en(•en just ignore error t) ® Piggott; PI ZDmi NayCenote(uport: Isgporatr; flag: 3001111): 1tGrit; PIP m: a sgPtr; (t Playing - in this version is for scalar valor of frequency only. • Minima value ii 201z, practical maxim is about 700011z. 116]1 *Period is calmlated fro. frequency to &Ids 127 0 500, otherwise, Woe • if the frequency is out of range of what we have in our wave tables Inn ad!egPtr(GtMg(upert)l; (t is a message there? t) • currently, we ban to reject the omod. t) IF (ani 811) t® (t Son was a neagel tl 1-4 f671 ~~

i1le416actOf foetid AMIGA so[ (t ma o' has seen this eq. so the system m allocate PPDCaleR Pfole61od1o(uport: WgPoatPtil; t Lb. lab !v tall& it ooean aoytS in t e More. va • Bow that we have received the siege at our on reply error: LONG= t) *Fort, it belongs to us and we on do bateau m net m: atlN¢t.r; (a B little bigger than a stadatd ueuga, • to it. Set tba reply port valu to zero now, u a signal 1: MGM; It but this routine will not really tow t) • to ange that It can really do that! (t (or rare) about the difference. tl t) BGII ao^.ruage.nplyPort IAL; II ((port i 8311 1® UM (t fus loop with muge t) Fal 1:Aalaaaean-1BI1W ®r arson. Pl(*Mhmellll; 1+'u la dma Satin mama q If (flag =ME) MR 210: (t let caller sleep while waiting for ey ldeotifled fab to app', tl aithrt(uport);flags= l' Nota: Bmi@ort does My x vs merge am pont t) ead (mrkxWome() = atsB) 00 flag:= f12: OaLy(121: (t An a good a6tihskinpg val¢bor: *leap a little q BBD; ®D: KID; RIM ( tlfier); l' mean the MG wenr t) Sr adsgptrlOetNaglWotl I: (a prePuze to at! the port') ® WycatBota;tiota; i®B (m t 121.1 DD aaN.msga.uplyPort>= Ba; (t lid system deallocate it t) m:= a0legPtr(0masg(1,ut)); PlaySa - play a sampled emend: ®t Identical to Playareq but the parnaters are lotupmtd dlffamtly. '£seep' now beam °parld" interpreted as sampling rate, Re aployIea; It free an static and dynamic messages t) zest be in the range of 127 to 500. p 'duration' still is amused ts 1000ths of a second to play it. FOR 1•=3 10 zaxfhm-1 By 100 lee with the audio device itself, a duration of 0 was do it forever aror:= aeefheooel(1); It error is day fuudlm Mum t) or until the audio dvice is rent or the canal is flushed or BU; until this coma is explicitly aborted.) Ue3etePort((port); 20; 2032012 PlaySaallthannel: IBD1It; (t specify cheroot embu 0-3 t) II (devlce t1a) 710 CloeOevice(AWlopenIe)1; ®; period: CAPBiUa; (• period value 127 to 500 •) FOR d-=2 DO mShan-1 BY 1 00 when: C201111; 1• vola 0-64 t) IF (dhipmdfolil t 0) yalP duration: CAMBIAL; (t 1000ths of a race t) Prxl4w(diwdioll), datalmgtB111): priority: Byte; (t fora a range -121 to 127') cbipudiolil:= 0; datalmgth111:= 0: mmgeport: WsggPortPtr; (t for use by NayG.tlote t) MID; id: LONOIIR); a (replprort(i) t la) y® DeletePort(replyPut(11); OD; VAR BU; error: MGM; II (owtrolport i Na) ?® DmietePutlatro@ort): B®; wavepointer: ADDRESS; (t are to find start of ample to play t) cycles: =DM; OD aWehAdio; !gnat, jpart: CARDINAL; length: 1,01202; YD Audlo7mis.5mp EECII eau:= IslatMyCbm(ohmnel): If ('or t 0) ?® MORE BID; hDW1S AudioD t: (• tut of the SlaTool libury zednle routines t) @ (paid > 500) puld:= 500; (a Note: ox reject it ? t) (t adapted to taiga lodada-2 by Anthony Bryant t) ESN (period a 127) MI perld:=127; PU; IRON SYS}) ABORT AW, s,egm,p@; @ (vola > 64) IBM vola_ S4; lED: PAW Andlo?ools DUCAT @ (rtipmdioldaonel] = 0) TIM 2I211; ➢D; (' no Seaton or Setamp 2•1 Idtdvdi*, Setmanoel, Stop%emel, StartChaoul, vavapototer:= rhlpmdiolrhanne2; Sett, Setxave Setae, Playlets, Phan, length. datalength(chaml]: (t as set by Beano a) IhyUUote, PlaySaap, CheckitDme, Pinishedio;

(t diode duration into two parts - 1pert a jpart - for calwlatlone a) RCN Arts May TemProoedne; II (duration > 1000) OPDI apart:= dmtiwm O@ 1000; Blah 1part:4; BID: jpart:= duratic - (ipart • 1000); Fa Dos lean Delay;

(t fool it a little so we don't get Integer overflow... a) PAW Inc 1WON? Byte, ley., Inlet-tits: (t 3.5 million times 1000 is about all we can tab In a 32 bit word •) IRI Radon (ter a@e? RID; cycles:= ((LWGCARD(audclotl) ' ipartlt(Le028D(audClok) t )part) ON 1000) DIV IttPDIlengthl • Period); PROD ?aminal Dee? Britain, BriteString; II ((cycle, = 0) ARD (duration t 0)) Mai cycles:=1: SSD;

w orms PlaymI(name),vevepoin',legth,puld,vola,cyalee, Tin priority,ressageport, id); waveAaay =nay 10..2551 WHITE: YUPB It jost ignore 'm t) CWS? OD Playbaep; missies = 1024; VAR 1: CARDINAL; (t If the mar says Plaisbkndio, @ IIS 113111 IDDID. ohmml, eros, yid: 101227: t Flush anything that is still in play, NW. You can eyport: NegPortptt; t on °CheckIfDmall" to see if everything Is finished sawtooth: waveAaey; t BU@S you call Flcisbkdio. If inecklfoonel) fa triangle: vasearay; • (FIRE), it mens that something is kill plying. square: 'eArry: t) simum: vavearay; noise: UM ((..miselu-1) (t BYal; H P• ~ Tm11tCCtOf Sar.aAMIGA adapts: IDfmS; 6ilttltrleq('Omued y 14-lwg flatlets and flags" 1; titan; PBOCOl11Y2+laMmTr m (• 0100 a m MIDDLE Pm, HESS OST 0IB891G10 t) i: nam; (t 1Wa to swarm q It Ids the note Sall a a can tall for sure tl titer; BPS; afa,mala,sty: aP; lt fast floating Point t) PlayMa(0, 3, O, 500, 0, Wort, 7); Orn titetttig('00nd up Peet of laasgL9 with id = 7'); tn:41; gv:427: aria Piar4.0r wW:4.0: ety:4•02/1: f0 i:= 50 10 95 IT 1 DO (t all motes, 1/1 mc. t) aa9tng(0, 10ti, 32, 125, 0, Ia, 0); M 1:4 TO 255 O I 00 2namhtij:- ya(ai - 11; Plaploa(1, 95-3, 32, 125, 0, in, 0): tsimgleldl :a Byaltn); IO; aq®n5110• BpalgT): titatrig('aened y 91-Prg Playbat and Pla3hege 1; •5annalll:• ya3aTDîa(II7.0 t 25a.)1; Trita6n; a (1>62) !m I1401 rm IBD(tn,z); EIS 11C(tn.2): ®; II lD1271 m• 2gv:a128; aO: PO 1:= 0 TO 3 BS 1DO m.fa:- cosine - (step * sine); wren= StatuLmd(i); tla:a ala a (step t eosins); II (era 10) 1m titasaig('6ror starting ,haall"); BBDO; PID; ®: sou; ® WWrel¢eyt; tltettringl'Starad all channels 0.1.1; tial; titela; PO®m s-; m ttttlalgl"Sa1P nov - the prioritised gid will mite a ,@.'1; 1: 00424; titeia; POO nrid:= xg+etPntela2Pntc, aAll: (t TUSK seas don't sleep t) r0 1:4 TO ameba-1 R 100 titan; (t Oa a cou• webs aaeeraar to get chit. t t nil Most t) titaatrL91'ty! lote I identified as 1; (t this Wallyreally could do with a leper array, But int the lack t) II I.y1d = 7) T® tiaSalg('11: 81O tlGtafng('0'); ®; ma.11l:= ya(127 - 101DI25611: titettrigl• just started to play*); Ion: tit•W: Sleek: oobeptr:= array; 101): KID titebtringelelt 6 seconds ... '1; Dklay(300); SOMAS Claemp; Triteetrlgl" CheclfDone ? - •1; BIM II (CaokIfeone() =TUSK) Om titettrigl•2B60.1: r import 1 IS) rm 2162 titeStrig('OO"); KID: ani.hldio0qport); Tritan; titan; tltatrigPDme1.1; lritestringl'lov pave up Playlets. with duration > 2000.1; titan; titan; KID; Playloa(0, 23, 32, 2000, 0, 1n, 0); HD Cl..ap; Playlotall, 27, 32, 2300, 0, in, 0); Playkt.(2, 30, 32, 2600, 0, In, 0); Elm lt LdioDm t) Playloa(3, 35, 32, 2900, 0, P14, 0); Tartmedare(Canp); (t don't lean m untidy Lipa t) titan; Tdtan; Delay(150); (t Tait. 3 seconde after letting the last note begin tltatringl"am of idlo2mL.'1; t (temnsa let na L 2900/1000th long). tltela; t) tLYea2srgt: NtOelairey; Tritestrig(Iast rota should have ended... I; titan; titestrlagr rkIfDoa?- '1: gpurt:= bit/silo (); (t an for tycatBOG and finish/silo e) II 43socklf0me() Tm tiagtrIng('10I"1; II (sport m) T® tltattrlglRrobla la IaltLdlal'1; ISIS; IND: ILS titatrlg NTBm"1; OD; Patel.; titan; I01:-0So3BT1DO channel:- OactLmal(-1); It any free channel ? t) (t aeip noise array to ch 0, using atsap() tl II (channel --11 Tm titaetrlgl"Caoot get a Swell 1. OTOO, tID, (t Satap(channel, sapleadio, length) t) trrer:- StgOaon•l(taoal): error:= Setsapl0, mleepa, noi.elml; II (erra t 01 rm tltatriglTraor in stopping chimed) ). MOO, NO, r (error t 0) MS Shearing (Inez la Seung, th.01; PBTODI; ND; 110; Tsltatrlg('Tinally, so* note, using PlaySaq'1; tit Ctring("got a Stopped 4 chamois 0.1.1; Writes; tite?a; PlaySmp(0, 327, 40, 6000, 0, In, 0): (t Playaay(t au, aspirate, velure, 6.0sec duration, pit, ngpt, id) t) It assign nwsmy. slog Sklanll t) (t s.tlanlchmal, wanarayl tl POI 1:=6 TO BT 1/3 (t try a 6 second decay of volute t) ana . SiMl0, aatootl; D07a/(501: II (error 1 0) TSO ttte9trlg(Trrer L Parlays, ch 0 1. PJaO, OD, error. SetP1(0,327, its); a®r:-Sattn(1, triangle); II (error f 0) T® tltattring(Brmr L SetPT, t.01; 1111211; OD; II (error 10) T® tlta6t5g(Rraor in letlan, i 11. MOO, m, ®; .roa:- 9stlan(2, t9iar.): (• If You take out this delay, you'll we that Mishandle mans 11 (error 1 o) Tm tiasalng("tnr la Set.lan, t 21: ISSN; Y0: t MIO 100X... it outs off the iotas right in the addle if necessary! t) aror:- Satlam (3, rLaanl; titestring("loin should have .clod.•); a (.War 1 0) Tm titeStdngiTacr la OekYn, ch 31; mm; DID; Rita; fiat; titialngl'Salan assigned all 4 minfn®'); tlhsalg(Mwdy to Plash Ld1o.1; It via T.rrhmcàre l t) tit.L; Mutate; OSOI; (t PLyaa(d+aal, aa/erg, rel, duration, prtalty,aa.ageport, a1 1 SD BudiaDao.d PO 1:= 0 TO Ii BS 100 (t all notes, 1/I tac. t) flaytg(0, loti, 32, 125, 0, m„ 0); Playlotall, 95-1, 32, 125, 0, III, 01; LI no; H Lsvf 1419- P•1 Transactor for the AMIGA 4❑ 1

Creating Run-Time Libraries

Adding your own functions to the system

by Steve Simpson, B.Sc.(Hons.), M.Sc. Copyright ®1988 S. Simpson

Steve Simpson is a freelance consultant programmer of the Figure 1 illustrates the block structure of a library, which com- Amiga and IBM PC. He is an ex-astronomer, has lived in Swe- prises the library structure and data areas, together with a table den for five years and translates technical documents. His cur- of jump vectors (usually six bytes wide) for the library rou- rent interests include systems, DOS utilities development and tines. These library routines do not appear with the main li- industrial process control. He is currently engaged in SideCar brary structure, but are loaded wherever there is space. routines development. He is the author ofDiskRepair, a disk editing/repair utility for the Amiga, which is available from him.

Anyone who has programmed the Amiga will be familiar with the use of nm-time libraries. These are either contained within Library Routine 1 die main Kickstart ROM (the most familiar being the graph- ics.library, execlibrary and dos.library which contain the Library Routine 2 graphics, Exec kernel and Amigaoos routines), or they are files with the .library suffix in the libs directory on the system disk. The run-time library lies at the heart of the Amiga's soft Jump Vector to 2nd Routine architecture. Jump Vector to 1st Routine I—Library Base Address As part of a larger project, I wanted to build a library in which Library Structure to maintain my most commonly used routines. These could Increasing then be accessed from my programs in the Amiga multi- Library Data Area MM tasking system; rather than keeping separate copies of the rou- 1 addresses tines in execution modules. This article gives a detailed de- scription of how a mn-time library can be constructed and added to the Amiga system. Figure 1: The relationship between the components of a run- time library and library routines. What is a run-tire library?

In a soft machine architecture, system routines and jump tables do not reside at absolute addresses. They are loaded into The OpenLibrary() function scans a list of library names memory when they are needed, wherever there is room for maintained by Exec, and from this list it determines the li- them. This results in a flexible system with efficient use of brary's base address. This address is returned in register DO memory; which is particularly important in a multi-tasking and the library data area extends to positive displacements system. Since them aren't any fixed addresses libraries are from it. easily upgraded. The library node or structure is defined in the C header file Note that, in the Amiga programming environment, the word execllibraries.h as follows: 'library' is used in two different contexts: (I) a collection of mn-time routines in Kickstart memory or loaded from disk struct Library ( and accessed via jump tables in RAM; (2) standard definitions struct Node lib Node; and routines used at link time which also contain interface rou- UBYTE lib_Flags; tines to mn-time library mutines. UBYTE lib_pad;

F • Transactor ram.AMIGA

UWORD lib_NegSize; The jump destinations are not always the same - they depend UWORD lib_PosSize; on where AmigaDos has loaded the library into RAM. Howev- UWORD lib_Version; er, the order of the entries in the jump table does remain con- UWORD lib_Revision; stant The jump table entries build downwards in memory APTR lib_IdString; from the library base address; that is, towards negative offsets. ULONG lib_Sum; Thus, by knowing the library base address for graphies.fibrary UWORD 1ib_Opencnt; (called GfxRate), we can get to any jump table entry by indi- I: rect addressing. If register A6 contains GfxBase, then the as- sembler command The individual elements of the Library structure are as fol- lows: JSR -48 (A6)

bb Node: a Node substructure. Within this, the In_Naine pa- will clear the screen. In assembler, the offset is either declared rameter paints to the name of the library; In_Pri determines as global in the assembler source file and resolved during link- where in the library list the library sits; In_Type is Nr_t.mRARY ing or is defined as a constant in an appropriate .i file. A glob- to show that the node is a library node. ally-defined offset would be prefixed with LVO and defined to be -48 (SFPDo), for example: lib_Flags: library flags: LIBF_SUMMING indicates that a task is currently running a checksum on the library; LIBP_CHANGED, JSR _LVOC1earDisplay (A6) one or more entries in the vector table have been changed; LTBF SUMUSED, the library designer wants a checksum fault to The offset constant in a .i file would appear as an offset be- cause a system panic (crash!). yond the standard library routines offsets, thus:

lib NegSize: number of bytes preceding the library structure LIBINIT itself. This yields the number of entries in the vector table. LIBDEF CLEAREOL Bb PosSize: number of bytes following the library structure. LIBDEF CLEARDISPLAY This is the data area LIBDEF TEXTLENGTH

lib_Version: version number of die library. Where t1131N1T defines the standard routine offsets (Open, lib_Revision: revision number of the library. Close, Expunge and ExtFunc) and the following would be used in the assembler source code to jump to the ClearDisplay lib_IdString: pointer to NULL-terminated text string which mutine: identifies the library. LINKLIB CLEARDISPLAY, A6 bb_Sum: currant value of the library's checksum. LINT U.m is a macro and is implemented as follows: lib_OpenCnt: incremented each time the library is opened, MOVE.L A6.-(SP) and deoemented each time it is closed. MOVE.L A2,A6 JSR -48(A6) As an example, we can look at the graphics.Hbrary. Its jump MOVE.L (SP)+,A6 table starts in the following way: The listings illustrate how to use both calling systems and how offsets to implement user-defined run-time library routines.

FFCA (-60) JMP $O OFC7FF8 Text Building a run-time library FFCA (-54) 314P $00FC7F98 TextLength FFCA (-48) 3r41P $00FC7CC0 Clearscreen The ROM Kernel Manual: Libraries and Devices (mar) gives FFCA (-42) JMP $00FC7C88 ClearEOL the code for an example skeleton library. However, it does not FFCA (-36) JMP $00FC7D24 B1tTemplate describe how to implement it and make it available to the FFCA (-30) JMP $00FC746A BltBitMap Amiga system. Additionally, deco are also a number of severe FFCA (-24) JMP $OOFC6CD4 ExtFunc errors in the RKM listing making it almost useless, as I found FFCA (-18) JMP $OOFC6CD8 Expunge out to my cost! FFCA (-12) J142 $00FC6CD8 Close FFCA (-6) 314P $OOFC6CD4 Open Listing 1 gives the code for mylibiibrary. The library code is 0 Library Base Address supported by libsupp.i and mylib_dej.i include modules (List- ings 2 and 3 respectively).

H TI 1-011- D~ Transactor fora"AMIOA Glo

The first instruction in the library sets the DO register to zero slmcl lnit [ and returns immediately. This is a safeguard just in case some- ULONG space: one tries to execute the library. ULONG funcTable; ULONG dataTable; The Rom-mg structure gives the system information about the ULONG initRoutine; location of setup mutines and data. Its format as a C structure ); (found in the C header file execlresident.h) would be: space - the total data space size in bytes required by the li- struct Resident ( brary. This is sizeof library structure plus user library data UWORD rt_MatchWord; space. struct Resident *rt MatchTag; APTR rt_EndSkip; funeTable - pointer to table of function initialisas a address- UBYTE rt_Flags; es to the library's functions (routines). UBYTE rt_Version; UBYTE rt_Type` dataTable - pointer to table of data initialisas. BYTE rt_Pri; char *rt_Name; initRoutine - pointer to the routine to initialise the library. char *rt_IdString; APTR rt_Init; These parameters are used as input to the MakeLibrary0 li- ); brary initialisation routine which is discussed later.

rt_MatchWord: RICJAATCHWORD (used to identify the ROM- In Listing 1, the funeTable: code references the absolute ad- tag structure). dresses of the routines in the library. These are the routines which will be allocated places in the jump table. These jump rt MatchTag. pointer to the next RoM-tag structure. table entries are usually six bytes wide, but four- or two-bytes wide entries can be used depending on how close in memory rt EndSkip: address of the library end code. the library mutines are to the library structure. In the case of four-bytes wide jump table entries, the mutines must reside rt_Flags: ROm-tag flags: either RTF.AUIOINIT a RIP_COLDS-TART. within 32K of the library structure. The table is terminated with -1L. rt Version: version number. If the first long word of the table is -1, then the table entries rt Type: RoM-tag type: either NT LIBRARY, NTJ)EVICE or are relative word displacements. The table is terminated with -IL. NT3ESOURCE The code for dataTable: in Listing 1 initialises the static data rt Pri: the library priority - usually zero. This gives the pre- structures. In this example we initialise the library stoicture feared location in the Exec library list with various values, but you could use this table to initialise your own data areas after allocation with AllocMem0. The rt_Name: pointer to a NULL-terminated name string. In this format used is the same as that required for input to the [nit- example library "mylib.library'D." Struct0 routine. This routine clears a memory area, preserving those words whose data and offset values are given in the ini- rt_IdString: pointer to a NULL-terminated string. This is the tialisation table. The macros used for dataTable in Listing 1 library's identifier tag and is used in library support and main- can be ilustrated by their equivalent C mixtures: tenance. It helps to identify different versions of a library, and its format is: struct InitByte UBYTE ib conmand; name version. revision (dd mom yyyy),CR, LF, NULL UBYTE ib count; UWORD ib offset; e.g. "mylib 1.0 (06 May 1988) \015\012\0" BYTE ib_value; UBYTE ib_pad; 0015 and \012 are octal equivalents of cat (carriage return) and l; LP (line feed).) struct Initword [ rt Irait: pointer to the initialisation table for this library. Points UBYTE iw_command; to a table of addresses for initialisation of data and any initiali- UBYTE iw. count; sation mutines. This table would have the following C struc- UWORD iw_offset; ture: UBYTE iw_value; );

~-1 1721 11 • II Ttatuactor kayo AMIgA O ~ struct InitLong b This system is illustrated in the example interface routines in UBYTE il_coi®and; Listings 4, 5 and 6. MyFuncO, for example, may be called DIME il_count; from a C program by including MyFimc00 in the source code. UWOItD il_offset; LONG il_value; Parameters could be passed to the library routines by putting H their values in registers, which is fine for calls made from as- sembla. However, C places function call parameters on the In the above, the command format is ddssnonn., where: stack and listing 6 shows how these values are extracted and placed in registers, before jumping to the called library rat- dd is the destination type (and size): tine. This represents a source of inefficiency when program- 00 - next is destination, mm is count ming in C. 01- next is destination, mm is repeat 10 - destination offset is next byte, min is count Routines must also reference the user's own library base point- 11- destination offset is next epi, mum is count er (eg. MyBose in the example listings).

ss is the size and location of the source: Interface routines could be kept in a scanned library and called 00 - long, from next two aligned words during linking. Example routine interfaces (all those with _ 01- word, form next aligned wad prefix) could be kept in the linker scanned object module li- 10 -byte, from next byte brary nry.lib. Il - ERROR - will cause ALERT Library routines written in assembla can now make use of non is the count or repeat register values directly. But what if a routine is developed in count - the (number+l) of source items to copy C? Listing 7 illustrates such a mutine: after entering the rou- repeat - the source is copied (number+1) times tine, the value placed into AO after extraction from the stack by the interface routine MyFunc2. is put back onto the stack. The offset is the offset into the data area to be initialised: in This is implemented as an in-line assembler command listing 1, we are initialising various parameters in the library structure. The dataTable sequence is terminated with OL. MOVE . L AO.-4(A5)

After MakeLibrary0 has allocated the library, initRoutine is where A5 holds the current stack pointa. In this example, - called. the user can include custom library specific initialisa- 4(A5) refers to the local variable VAL in the routine _My- tions in this routine. In the example, Listing 1, copies of the Func2. This convention is compiler-dependent - and you will system base pointer, the library segment pointer and the nos need to check your compiler's documentadon. library base pointer saved. The DOS library is also opened, oth- erwise an alert is shown on error. We can then perform the example calculation and return the answer in DO. (Note: we use _MyFunc2 to differentiate from System interface _MyFunc2 - the first is the library routine in C, the latter is the C calling interface to _MyFunc2.) A library must have a minimum of four standard functions: Open, Close, Expunge and ExtFunc. When the user calls OpenLlrary(), CloseLibrary0 or RemoveLibrary0, they will Using the run-lime library eventually be translated into Open, Close or Expunge. Ext- Pone is reserved. The user-defied run-dine library is opened in the usual way, by a call to: User library routines are positioned after these functions. If a routine is developed outside the main library source code, then libBase OpenLibrary (name, version); it must be declared as global (using XREP in assembler). User murines can be developed in assembler a C where: struct Library *libBase; (or any other language). These routines am linked to the main library code during the linking process. The version number allows the use of different versions of a library. Listing 9 illustrates how the library is opened and Interface for calling library mutines closed. It also shows how to call the user-implemented library routines, MyFunc00, MyFunc10 and MyFunc20. Amiga convention uses the A6 register for the base address of the library being called. Registers DO, DI, AO and Al are After finishing with the library it is closed using: scratch registers and are used to pass values or pointas to the library mutines. DO is used to return a value from a library C1oseLibrary(libBase)- routine.

4-I 12-1 I-19r Transactor forth* AMIGA AIM

Installing a library in the system Debugging libraries

The component parts of the user mn-time library are assem- This section could, in itself, form the subject of a complete ar- bled or compiled with the option to omit the begin (for Main ticle. We can't hope to cover more than just the very bones; users) or startup.obj (for Lattice users) routine. We don't need most of the discussion comes from first-hand knowledge of the load code since we are effectively providing our own. All trying to fathom out such questions as "Just where did that components are then linked along with the standard Amiga li- pointer go to??". braries. The resultant file is the nm-time library file, my.library in the examples given. Firstly, a word about parameter passing from C routines to as- sembler. You should determine the parameter passing conven- Listing 8 illustrates how a user-defined mn-time library is tion used by your compiler. The ability to enter assembler added to the system. The library is loaded into memdory by code directly into the C source code is a distinct advantage. Loadsego. A call to MakeLibrary0 initialises the library's jump tables, sets up data areas and performs user initialisation. If possible, try to debug all routines external to the library un- Parameters to MakeLibraryO include a pointer to the table of der development. This will prabably entail opening an incom- library function addresses, a table of data initialisations, a plete library in order to mak calls to existing routines within it. pointer to the user library initialisation routine, the space re- It helps to have a good debugger, especially one that will al- quired by the library in bytes, and a BceL pointer to the seg- low source code debugging. ment list returned from LoadSegO. The space required param- eter is the size of the library structure plus and user data mea Ensure that the order you assign for your routines in the li- The call to MakeLibrary0 looks like this: brary function table matches that order specified in the assem- bler header file defining tmINrf (in the example: mylib_def.0. libBase = MakeLibrary (£uncInitr strucInitr libInitr dataSizer segList); Summary where: struct Library *libBase; The concept of the run-time library increases the efficiency of the Amiga system, allowing programs to use a standard set of If strucunit is Nat, the InitStructO function is not called; the routines. A user can keep most commonly used routines in a library either has no data or the data area is specified in some nm-time library. This article should clarify an area of the other way. If libinit is emu, the Ink routine is not called and Amiga environment that is not well documented in the litera- the library is not initialised in the usual way. true. Devices and resources am closely related to libraries and this article has served to introduce their implementation by MakeLibrary0 rearms a pointer to the library base (libBase). showing how a library is created This pointer is used as input to AddLibrary0. which adds the library name to the system library list, thus making the library the example listings were developed using the Manx Aztec available to every task. The library is not opened by AddLi- C68IC v3.60a C compiler and assembler, and debugged using brary0. the Manx 5DB source level debugger.

There are, in addition, two other ways of making a nm-time li- brary available to the system. These methods am probably eas- ier, but for them to work, you must follow exactly the library format given hem in the assembler examples. Further reading

On issuing an OpenLibrary0 request, the system will search ROM Kernel Reference Manual: Libraries and Devices, Addi- the list of available and installed libraries, If a match is not son-Wesley found, the system looks for the specified library in the directo- ry specified by the Amigaeos logical device ams:. If found, RoM Kernel Reference Manual: Exec, Addison-Wesley the library is loaded, initialised and opened and a pointer to the library base is returned. The Kickstart. Guide to the Amiga, Ariadne Software Ltd.

Alternatively, a library may be saved in the :Expansion direc- Commodore Amiga Inc., The AmigaDos Manual, 2nd Edition, tory of the system disk. (Useful if you have, for example, a Bantam SideCar/BridgeBoard.) A Workbench icon info file must be created for the library, and should be named .info. On boot-up, the routines contained in the tion, Sybex expansion.library will kick in the :Expansion directory, load- ing and initialising any libraries with the info suffix. Williams, S., Programming the 68000, Sybex D • Q Tmnaaeior tor aMAhfT6A 1414 Listing I: ;ens and raalb look for this structure during tie loading apaark° ;to discover such as Were to start rowing it, for maple. ;In C this weld be egninlent to the bolded structure

; wlib.ata — eaeple library code InitLiiheaip: ;stnchute IT,0 de.r Rm MEWS )WC 02110211010 hsple of how a user system na-tie library is constructed. dc.l initL160esalp :Wm @ IBS®0 dc.1 bdLibCode ;IPm RIND= ; History: t.b El IgmnlT ;ISM R PUSS W-05-06 canted by Sten Simpson dc.b PWffiW ;WTW @ g6A0

; various definition and equates dataRable: mars n Tyn,W_1nRIRY it/PRI IV 0 ;lib priority - Position in system library list NIECE 18 alH.wba gnSIW @g0 1 valor version maker NI[REN Ln sWES,tffi SmHnOILIn MEW 1a

w e.l a5,d0 ;unlink tau library Het rve.1 (sp)t,a5 wove./ a5,a1 its MUM Porro

;System interface tends begin here. ;library specific closings here ;Calling OpenLibaay/Clceetibnry/Bmvetibruy translates Into a call ;to the ratines Open/Close/Expunge. ;The library bave pointer is in A6. Task slitting bas been tuned off ;close the dos library ;tile Is these routines Nia Forbid/Zenit), so don't hang abut' move./ ti DosL6b(a5),al cALLSis Clmeiihnry ;free oar memory ;Open returns the library pointer in DO if the ope was socessfrl. C RIR dD ai the open failed then null is returned. novel a5,a1 rw.v LIB BAGSIZE(a5),d0 Open: ; (llhptr: A6, version: DO ;inoses library opo cooter sub.! dO,al addq.v f1,LIB WWQ1(a61 dd.v LIBPOSSI+SId),dO ;prevent delayed apmgea CALSUS ?ream belt JL11613 DE!ZXP,.I Flags(a6) ;setup ou stun value - the eeglist enve.l a6,d0 rve.1 d2,d0 its BapmgeEnd: anm.l NO?, ai the library is no longer apo, Close returns the segment list if its ;the delayed expunge flag is et. Othertiee Close return WL1. Close: ; (lltptr: a61 ;ErtPunc just returns 0 In DO register. ;set the robin valu CLEAR CO EttPmc: CLEAR dO ;decrement library Cpm canter rte s,bq.v f1, L11OPSECPf(a6) :anyone got us open? ;The library specific coeds begin hen ine.s 1$ ;In this ample library there an 3 library specific rating - ;the third flyback Is vrlttu in C, and is included in the lint

~

transactor fora».MMIGA 1 =U 4 b :list for the library. 08680 ml SegList 08TT1 ml Plags warm ml.pad L89HL XyLtb Sireof ; Myrna - just returns value 0 in the DO register ;—name of my library lyfmc0: X610014 liliCRO CLB1R m do.b 'mylib.11brary',0 rts 8801

Xyroncl - returns contents of register 16 in the DO register Listing 4: I

!¢Pmol: morel a6,d0 ; mpfmc0.aem its ; Interface between calling program and jump table for myllb.library ; routine XyrmcO ;mie is the end of our library code ; History: SadLlhCade: 88-05-06 created Lm

10LIST IBCIBDE "exec/types.!° Listing 2: I IICLODE "exec/libraries. i" mcwoE "llbupp.l" DELUDE "splen def.1" 11Wupp.1 LIST

swlrmmtel macros 3118 lipase LMP Hyrum° History: 88-05-06 created ; C calling sequence: ret = Xylmc011: registers: dO C®4 IRCRO tong 10,\1 XynacO: H~1 :--put library base into 32 register move.l I1yBase,a2 LEM PYRO LDW,ID LVO\1,U :-mob routine call ebON Li1RLia I1708CO3 a2

CALMS ![ACRO rts CILLLIS LVO\1 00X Ste

HLIB XBCRO LMP LVO \I Listing 5: 1 01011

Listing 2: 1 myfuncl.ame

Interface between calling program and June table in rylib.library ; spllb deft for satine Xdpuncl

; assembler defines for myltb.librery History: 88-05-06 created History: 88-05-06 created DOUBT 111=8 'exec/typee.i' ;—library function offsets from base structure Ben 'exee/li rariea.if =BIM 1RCton '1lbsupp.i' MDQ 1140411C0 INCUBI 'mylib def.l' =MP Krum LIST LIMP IHHL. -- DSP Xflia s ;tiyllb data area structure - this is appended to Library stnotare YR -Nyland :—at offset LIB SIM Bm0.100 XpLib,I,IB 088 0080 sl SysLlb ; C calling sequence: ret t l Punol11: BLOW sl Dosl56 regslten: 610 y 1771 I--/1f

I • Transactor mrmeAM7GA

Matta: • compile: cc ib myfmmvd :—put library base into d2 register * we don't need the start.up code far this module urn.! NpBase,a2

;—jump to library table linclnd cuec/types.b> LIm,1B I0201C1,a2 pnnu**aa**u*ntttntuuuOSatt****at**mu****Sa****n** rte • Assembler call' Input register: a0 END uanu***n**uueanmm******mnuanutaunaun•/ EON6 Ryland()

BUNG ni;

/* assembler directives 1/ !an ;—ftia is ray library interface - it gets the value put into register ;-10 by the routine Nand. Listing 6: I ;—Ae value is then put into the local variable before being used ;--by this C routine ;—Register 45 is the local stack pointer, Me compiler allocating mytunc2.aem ;-spaea on the program stack for this rootlets local variables. mave.l a0,-4(a5) Interface between calling program and jump table in mylib.11bnry tendase for routine 11unc2 /1 d the example calculation */ ; History: val t vals 2: 88-05-06 created /* return the value - this goes into d0 */ NOLIBy retunlvall; l8CID06 •emac/typn.i° INNODR 'emec/libnriee.i• 1 /* end Nynec2 */ IRCIADR 'llb•upp.l" INCUNH °mplib def.i" LIBg hieting.e: I /RV lipase t*a!leaf* nt*mumuw rani Sant* n•tl IIBB Nand !t•nntnl*ute•gtl ad11h.c

Male to add a user library to the library list maintained ; C calling sequence: ret = Nynmc11va1: by the system. liter adding the mer library Is available to registers: d a0 all subsequent programs

c2: History: B8-05-06 created ;--get input value from stack into register move.! Qeple° compile: cc ad lib link: ln addllb -lc :—put base into register crutsint**tlmiatatttat)muu**enutannuntnunl*neeq move.! Ny!ase,al !include !include cexec/types.b> ;—nov jury to the library jury table !include 4nc/libraries.h> LINBLIB N!PHNC2,a2 !include ceaec/resident.h> !include libraries/dos.h> rte !include dlbraries/dosextens.h> !include myllb.h> Ben EOM segllat, /* EMI seglist pointer */ codeloc; /* pointer to code location •/ Listing 7: I struct Ait I Idittnn**tit•ttnnt***ntitlttit*1•â*1t1*t*1•it Htttt*tnn It NAIL space: /• data space sin •/ myfanc2.c WIC fundable; /1 ptr.to foot offsets table t/ DIW6 dateable; /t ptr.to bitstnct table II C ratine 1 MyBnnr11 installed in library. OM116 initP itine; /* ptr.to library inithootine */ Bina an making a call to a library routine in the assembler I finit; interface data are put into registers, then we mat recover the data and put them into local ?ambles ie any C routine. struct Resident •ll ales; /* ptr.to library ram tag area */

I/story: NONE apace, linable, dtahble; iafanotine; as-05-06 created • fi Tfan6aetOf aau»AMyCA street NLlbvay 421n;

/f fuoc0 resets the DO register and return in value t/ man ret =igym0(1: prfntf(•ret(0)=11x n",ret);

/t load the library segment t/ /t furl puts 16 into 00 and return it t/ cegitst = (uLARO)LoaiSeg(•=yln.11brwy"I; ret = xigmcl(); if IagListlfLL) printfrrek(1)=1.1a\o",ret); printfran't load myln.libaazy\n9; eait(0); /t food mltlplles vat by 2 and pots answer into DO for return 1/ val= 10L; ret = ilyeunr1Nai); /* address of start of library cade ln weeny prlotf("ret(2)=ald\o",ret); * wltiply by 4 since mint is a h3L pointer t/ lee = agha t 1; /* close my library */ Closellbrary(Ify8asel; /t address of library resident rua tag data area t/ lites = (strict Resident *1(codeloc + 8);

/t address to nitialisattoo data table t/ lait = (street mit g1lbRea-nt n1L;

P extract data from initialisation table f/ Listing 10: space = init->space; fundable= trait->fwetable; /Xfbt)Httktttttuatttttnnt titintnttltntnttn hilt tt t tit dataTable = init->datatable; * mylib.h InitReetfne = init->taltRoutine; t * defines for use with myllb.libary /5 initialise the library 5/ rylib = lstact ItyLlbary t}HakeLbrrylfumcfable, datattble, t History: nitRoutine, space, eaglet); * 88-05-06 created naivauaattuaatttftttttftuttttauttuattmmuffy /t make the library now to the system *1 iddLibrary$tllbl; Include Uac/types.h> Include nm/11Daries.b> prnt!royllb.library added to syatem\n'); Include taxa/axe hase.h> Include Atbraries/dosextens.N

/t nylib library structure - this 1s C version of that defined in t ayllb def.! t/ Listing 9: I strict "library ( strict Library ml IIylb; n utttntttttttttHtttttefttffltttitttlMtat@!!t@fNttfttttt street Ewa/se 4l SysLtb; my maln.e street DosLibnry tent DaLib; NPR ml SegList; teat program for mpllb.11brary OBYa ml Plags; OETTH Wind; History: 88-05-06 created by Steve Simpson Idafna HO,IeRAte •myln.libraty" cmplle: co ay main link: In my-win -nyln -le triutttutttttttttttttuttttnnttit tau tt *then ittitttttuttt/

Include Include tem/librazies.b> Include tmyiib.h>

/t my defined library base - this global and is accessible to the k assebler routines t/ etact IyLlbnry t1 Base;

main()

moat ret, val;

/t open my library 5/ /flue = (street eyLlbrery t)OpenLtbrary("myllb.library",7L); if IRyOase-M,1) ( prntfl"Can't open myllb.11bary\o'1: nit(0): Amiga Hard Disks Compatible with Amiga 500, 1000 and 2000 [All boxed with power supply and relavent SCSI interface]

20 Mb 65ms Hard Drive . .. £495 inc. VAT 40 Mb 40ms Hard Drive . . .. £595 Inc. VAT 49 Mb 28ms Hard Drive . • . £695 Inc. VAT 60 Mb 40ms Hard Drive . . • . £695 Inc. VAT 80 Mb 28ms Hard Drive . . .. £995 Inc. VAT THE VD3+ REAL TIME THE AMIGA CRP COLOUR DIGITIZER GRAPHICS TABLET PAL AND NTSC - £795 +VAT A3 - £595 +VAT A4 - £360 +VAT The VD3+ allows the user to take an input from any vfdao Resolution: 0.1 min, or 10 point/m.m., or 250 points/Inch source, including tape, and digitize it in full 4096 colour in Absolute Accuracy: +/-0.5m.m. (0.0201 Amiga format Compatable: Dpeint Il, Graphicraft. Digipaint. The Bernoulli Box II 51/4 ' Removable Hard Drive. Now available for your Amiga

Reliability. The head floats at a height of 10 millionths of an inch above the * COMPATIBLE WITH AMIGA 500, 1000 disk surface. The practical result of this "sot contact is minimal AND 2000 wear to the disk and minimum chance of a head crash. Transportability. * CAN BE SPLIT BETWEEN AMIGA-DOS The compact disk cartridge Is virtually indestructible and AND MS-DOS absolutely interchangeable from one Bernoulli to another. SecurIty. * IDEAL FOR ANIMATION, GRAPHICS Backup is simple and the disk cartridge is easily stored in asafe. AND SOUND APPLICATIONS The Bernoulli system can be purchased as an internal unit for the or as a single or dual external unit for all machines. The external units are supplied with power supply This proves to be a very cost effective way of storage for seriou and have a fan fined A SCSI interface and cables are supplied Amiga users as you can use as many 20Mb cartridges as yo with all units. require at a cost of £ 65 per cartridge. Internal Unit £ 865 Single External £ 995 Dual External Unit £ 1695 Above prices do not include VAT POLAROID PALETTE The system allows the user to take full colour pictures of the computer screen and produce 35mm negative or slide. INC. Amiga Interface Polaroid Palette Image Recorder Polaroid dedicated 35mm autowlnd camera back Polaroid 3 1/4" X 41/4 print and overhead projection transparency camera 35mm Power Proccessor Iluminated slide cutter/mounter Software and Manual £1495 + VAT Burocare Graphic Design Ltd. 211 Kenton Road, Harrow, Middx., HA3 OHD BESPOKE AND TRAINING SERVICE AVAILABLE Tel. (01) 907 3636 Fax. (01) 907 0027

707.887.9708

p,p. BOX 1389. GUEQNEVILLE GA. 95446

ou'll dis- other month, Y AMnews. Every we've dot. a Owner, , you'll love the New But news isn't Amiga one nu what they was q t news from the Amiga publications alldo didn't realize AMnews Even i£ you most We're letting paper {ving you real games, cover three disks packed fullyears of the beyond curies articles d productionand reviews' can do even better. Like q cover animations with soundtracks- We- light Ye work New AMnews is #a right beside eye boggling useable, not to mention ogr cnls in everyYaissue, l n graphics do well while we do what a your commercial programs s miss the dazzling productivity tis macros that make eyou won't want ou decide to unities and p Tates and decisions. And CLI lessons either. Whether Y scroll- temp ease your buying system (with smoothlyde have the t l art and if-running ing demos of newprograms magazine-like operating Y Mmakes spossiblepossible and our its renowned mag How AMIGAl piing usingou simply sit back and watch it ALL in the hands-free se ONLY sona re thrilled with each and every NewAMnews r or less thanbut you can take a look for yourself; here viewtext at YOUR personal reading speed) you be nothing fi u the best — rst ingE ou won't miss a thing),Y DEMO modeode Well,(soy we're committed to bringing Y the to bring programs and also teaching doare we some know of the goodies in our first couple of issues:used in Amiga built around techniques program's s t~ ally reduce the pr°gram s Art and music lesson ea ~Y Word that dramatically between YOU. lre1 WordPerfect Corp.) that transfers files { the artistin with a tutorial and oordn ou Editor ■ erfe an Macro i ram (also programmed complete with omPl d a Conversianprog h Wordprocessor. and Leo Schwab — complexity, now, that other Louis Markoya 4 wwell, you k tike Scribble- and, trend-setters , with • {ioris by Amiga art and anima • is touch- the latest goodies from BgSs and networks ~ Dazzling add that mag rab sound tracks that so that you, too, can g on disk. NGG s organizinganrzrng programs CLI and MULTITASKINMy downloadinglou cin sessionprocessing and interactive set priorities Interactive down hands-on rename and move files, after-transfer instructions on p the icons themselves) and so you can ono (w prompt t> 1 Lessons on setting up ie one (well,okay, o Y CLI believe for Max- • at square have to type in. (wouldyou T ting templates al john Foust,ous Shel- Lessons Startup-Sequences you DON' sounds, tempons Mrc and use animations, super by well-known Amig ames, dazzling , s Hot playable g S~ ~ and informative articles graphicsra g rbase Pro.) h t) yours truly. ue of NewNew AMnews — g p - and n, MatthewLeeds and (ahem!) features in every issue land freely distributa n off ALL Amiga f of dondon Leemo~ ~owingwe're b helping you get the most from comm much more ta5 ++ And much, multitasking —besides help. music, speed and mu=•- ble programs.

d Transactor (U.K.) Limite SWEDEN!SCANDINAVIA Unit 2, Langdale Grove Bingha The NETHERLANDS HK Electronics hire Sala Communications 1873 392 90 Nottinghams ENGLAND NG 13 8SR 2152 634 31 Or call us at the New SWITZERLAND AMnews in We'll be glad to help You! Elepro AG 01 830 2000 Compatible with Amiga 500, 1000 and 2000 [All boxed with power supply and relavent SCSI interface]

20 Mb 65ms Hard Drive . ■ • . £495 inc. VAT

40 Mb 40ms Hard Drive . ■ MI . £595 inc. VAT

60 Mb 40ms Hard Drive . ■ IN . £695 inc. VAT (Larger Capacity Available POA) THE VD3+ REAL TIME COLOUR DIGITIZER PAL AND NTCS

£795 +VAT The VD3+ allows the user to take an input from any video source, including tape, and digitize it in full 4096 colour in Amiga format. The Bernoulli Box II 51/4" Removable Hard Drive. Now available for your Amiga

Reliability. The head floats at a height of 10 millionths of an inch above the * COMPATIBLE WITH AMIGA 500, 1000 disk surface. The practical result of this "soft" contact is minimal AND 2000 wear to the disk and minimum chance of a head crash. Transportability. * CAN BE SPLIT BETWEEN AMIGA-DOS The compact disk cartridge is virtually indestructible and AND MS-DOS absolutely interchangeable from one Bernoulli to another. Security. * IDEAL FOR ANIMATION, GRAPHICS Backup is simple and the disk cartridge is easily stored in a safe. AND SOUND APPLICATIONS The Bernoulli system can be purchased as an internal unit for the Amiga 2000 or as a single or dual external unit for all machines. The external units are supplied with power supply This proves to be a very cost effective way of storage for serious and have a fan fitted. A SCSI interface and cables are supplied Amiga users as you can use as many 20Mb cartridges as you with all units. require at a cost of £ 55 per cartridge.

Internal Unit £ 865 Single External £ 995 Dual External Unit £ 1695 Above prices do not include VAT POLAROID PALETTE The system allows the user w take full colour pictures of the computer screen and produce 35mm negative or slide. INC. i Amiga Interface Polaroid Palette Image Recorder Polaroid dedicated 35mm autowind camera back Polaroid 3 1/4" X 4 1/4 print and overheao projection transparency camera 35 mm Power Proccessor Iluminated slide cutter/mounter Software and Manual

£1495 +VAT Burocare Graphic Design Ltd. 211 Kenton Road, Harrow, Middx., HA3 OHD Tel. (01) 907 3636 Fax. (01) 907 0027