home *** CD-ROM | disk | FTP | other *** search
-
- Ez.lib and Ezlib.h
- - two things that will make your programming life easier -
-
- by
- Dominic Giampaolo
-
-
-
- 1. Introduction
-
- I have recently started into heavily programming the Amiga. Since
- then, I've noticed that at times it can be *very* difficult to even get
- simple things done. To that end I have started working on Ez.lib.
-
- Ez.lib is a link time library which has high level functions to
- accomplish many of the mundane tasks of writing an "Amiga" program.
-
- The Ezlib functions have been designed to simplify the normal process
- of creating windows, gadgets, screens and other things. This is my first
- stab, but for the moment it serves my purposes quite well. Hopefully it
- will do the same for you.
-
- Using Ez.lib is also straightforward. You simply #include <ezlib.h> in
- your program, and link with ez.lib. That's it!
-
-
- -----------------------------------------------------------------------
-
-
- 2. What's included?
-
- There are routines to open screens, gadgets, windows, get string input,
- get yes or no answers, use disk fonts, open libraries, and of course
- closing all that stuff down. Now when I say "opening screens and windows",
- I mean it - you'll see (read: no silly structures to painstakingly fill
- out).
-
- Probably the nicest function (IMHO) is the makescreen() call. Here is
- all you need to do to open a HiRes, Interlaced, 3 bitplane screen:
-
-
- struct Screen *screen;
-
- screen = makescreen(HIRES|LACE, 3);
- if (screen == NULL)
- no_screen();
-
-
- That's it. *Everything* is handled with a single function call. You
- simply specify the modes you would like and the depth, then presto.
-
- Compare this to what would normally be required. Notice you didn't
- even have to bother opening grahics.library or intuition.library! The
- makescreen() call checks those trivial things and covers your butt.
-
- Of course it wouldn't be nice if you had to go through the rigamorole
- of closing and freeing all that stuff. To that end, killscreen() takes
- care of you, and with a single call, everything is properly deallocated and
- closed down.
-
-
- Now the first thing most people will say is, yeah great that's really
- nice, but what about { performance | size }?
-
- Performance really isn't an issue with these calls as you don't sit in
- a loop creating custom screens (at least I don't ;-). And if it really
- does matter, the code simply has a few if/then combinations to make sure
- you get a valid screen. Certainly nothing computationally intensive.
-
- Size wise, the extra code for checking various parameters doesn't
- amount to a hill of beans. A demo program I wrote that uses *every*
- function in the library is still less than 9K - it accomplishes a fair
- amount too, and is one helluva lot easier to understand!
-
-
- -----------------------------------------------------------------------
-
-
- 3. Let's go over roughly what is in Ez.lib
-
- These are short descriptions of what each function does. The complete
- docs for each function are in the doc directory.
-
- Function Name What it does
- ------------- ------------
-
- openlibs(which_ones) Open the specified libraries. Which
- libraries are opened depends on the
- argument you specify. Can easily open
- multiple libraries at once, error
- checking each as it goes along.
-
-
- makescreen(modes, depth) Opens a screen of said modes and depth
- allocates any necessary bitmaps, etc...
- Can handle any Amiga screen mode and
- depth (not overscan though).
-
-
- makewindow(screen, Open a standard Intuition window with all
- l_edge, t_edge, the trimmings. Put it at l_edge (left
- width, height) edge), t_edge (top edge) and give it
- width and height for dimensions. If
- screen is non null, open it there.
-
-
- makeboolgadget(win, Create and add to your window an auto-
- l_edge, t_edge, sized boxed boolean gadget. The top
- text, id) corner will be as specified and the width
- and height are figured dynamically. The
- string will be centered in the gadget.
-
-
- getstring(screen, Pop up a window with a string gadget to
- title, default) get input from the user. The window will
- have the given title, and you may give
- a default string to place in the string
- gadget.
-
-
- getyn(window, string) Use an AutoRequest() to get a yes or no
- answer from the user. The string you
- specify is put in the requestor.
-
-
- getfont(name, size) Open a disk based font for use in a
- window or screen. You specify the name
- of the font and its size, and the rest is
- taken care of.
-
-
- There are also functions to close down/deallocate the items you open
- with these calls. You are not required to use the "kill" routines, but
- they are guaranteed to be safe, and will free any previously allocated
- memory and generally be smart about closing down.
-
- In addition there are a few lower level calls that give more
- flexibility in the objects they create. This is at the expense of a
- parameter or two extra which you must specify in the function call. There
- are also two low level bitmap allocation/de-allocation routines.
-
- -------------------------------------------------------------------------
-
- 4. General
-
- These functions certainly don't cover everything you will ever need to
- do on the Amiga, but they do make many things easier. For example, you can
- now try out the graphics in your Amiga without having to worry about all
- the nitty gritty details.
-
- As a similar example, I wanted to write a program to draw Lissajous
- curves. First I was daunted by having to drag out the RKM's and start
- going through the NewScreen structure, etc. Now I simply call makescreen()
- once and I'm ready to start drawing the curves! The entire source to draw
- the curves is now less than 1.4K - and the bulk of that is simply setting
- up tables to make the calculations faster. The executable is around 6K.
-
- Using the getstring() function you can even create simple
- Intuition'ized programs without any more effort than it would take to call
- the same character/line oriented function (gets() or similar).
-
- And with the ability to trivially create boolean gadgets, what more can
- you ask for? A completely Intuitioniz'ed calculator program could be
- created without much effort at all.
-
- As you can see, the functionality in Ez.lib will definately make many
- programs easier to write and debug. You don't have to worry about making
- sure you properly allocated the bitplanes you needed, or making sure you
- did it right. Instead, you concentrate on your code, knowing that the
- Ez.lib functions will cover the rest.
-
- ----------------------------------------------------------------------
-
-
- 5. Any thing else?
-
- Well, the real docs for all these functions are in the individual
- files in the doc directory. The return values and methods for calling them
- are also documented there. In addition, there are code fragments in the
- documentation that directly show the complete calling sequence for these
- functions. Hopefully, using these functions is straightforward.
-
- I will probably continue to add functionality to the library as needed.
- I'd like to cover a lot more things (mainly other types of gadgets), but
- for now the library is sufficient to be usable.
-
- I'd like to thank Dan Drake and Bob Koon for both listening to me
- babble about this library and for giving me some good input. Thanks guys.
-
- Finally I'd like to give credit to the _Amiga Transactor_ (god rest
- its soul :) for having had excellent articles from which I learned plenty
- (and from which some of this code came from!). In addition, I would like
- to thank the many nameless folks who have distributed public domain source
- code for doing various things on the Amiga. I've learned a lot from that
- code - thanks. And finally the folks at Commodore who wrote the RKM's, if
- it wasn't for them, I'd still just be using WorkBench ;^)
-
-
- If you are interested in contacting me about bugs, problems, or
- questions about EzLib, you can reach me in the following ways:
-
-
- E-mail : nick@chopin.uunet.uu.net OR giampal@auvm.bitnet
-
- SNail Mail : Dominic Giampaolo
- 4201 Mass. Ave.
- Apt# 8067 West
- Washington, D.C. 20016
-
- Of course I'd really like to hear back from you if you have anything
- (good or bad ;^) to say about these routines.
-
- Oh one final thing. This code is totally free for you to do whatever
- you want with - excluding selling it for outrageous prices, saying that you
- wrote it, or any other generally evil things. Essentially this is in the
- spirit of GNU - code for anyone to use and learn from (however this code is
- not under the GPL).
-
- --dominic
- 08/09/90
-
- ************************************************************************
-
- NOTE: The library that is included in the distribution is for Manx 3.6.
- If you use Manx 5.0 or Lattice, you WILL have to recompile the
- source and make library from the object files. I don't know
- Lattice, but I have included a Makefile for Manx, and it shouldn't
- be too hard to do for Lattice.
-
- ************************************************************************
-
-
-