home *** CD-ROM | disk | FTP | other *** search
- <head>
- <title="...forever...">
- <font=monaco10.fnt>
- <font=newy36.fnt>
- <font=time24.fnt>
- <image=back.raw w=256 h=256 t=-1>
- <buf=2302>
- <bgcolor=-1>
- <background=0>
- <link_color=000>
- <module=console.mod>
- <pal=back.pal>
- colors:
- 251 - black
- </head>
- <body>
- <frame x=0 y=0 w=640 h=2302 b=-1 c=-1>
-
-
- - -- -- --------------------------------------
- <f1><c000> .: GEM in one pill :. <f0>
- ----------------------------------------- - --
-
- compiled by Saulot / Nokturnal / Chosneck TEAM
- 1.11.2003
-
-
- 1) Introduction
- ---------------------
- The GEMcandy competition is near. So I thought is a good moment to remove the
- layer of dust from the long forgotten and ancient wisdom called GEM
- programming. I haven't found many sources of information in one concrete piece
- that could show how to start. You can find numerous function references in many
- books and text files scattered on the web, but how to use them? Well, I managed
- to compile the information from various sources (mainly from really great
- Jonathan White's and Tim Oren's tutorials which are more or less complete) to
- show how GEM applications can be done, discussing various topics, how to fully
- manage them in step by step manner. In this tutorial you will not be able to
- find the complete references to system functions (no time, no space). You
- should look at the better resources like "Atari Compedium" or another one. The
- second reason was that at this moment there are several really great GEM
- libraries, but without good knowlege about how the functions work and what for
- they exist you will not be able to do anything.
-
- Before I start, I would like to excuse for omissions or eventual errors. If you
- find something very offensive, some fatal errors or you simply want to point
- out what is still missing mail me. The handling of more modern OS'es like MiNT
- or Magic is not covered here also protocols like OLGA, VA_START, DRAG&DROP,
- BUBBLEGEM and various system extensions ,because I haven't much resources on
- this topic, but you should be prepared to see it in the near future revisions
- of this tutorial. I would like also to see some feedback on the tutorials that
- I wrote (or still writing). I really need it. I know that for now the audience
- of Chosneck is quite small (lack of ST/E shell, ST-RAM hunger and several
- incompatibilities), but it should be fixed now from several reasons. One of
- this reasons is a website done by me about 16/32 bit Atari programming
- (http://www.republika.pl/nokturnal). There you should find most of my articles,
- (hopefully) download Chosneck magazine and maybe read all the articles online.
-
- 2) So we start!
- ----------------------
- At the beginning and end of every GEM program several steps should be taken:
- - the initialisation of AES (if error then quit)
- - the initialisation of VDI and opening of the virtual workstation (if error
- occurs then program can run, but this is not recommended)
- - loading of RSC resource file (if not possible then quit)
-
- RSC file considerations
-
- With resource files we have two considerations. We can load them during program
- start or embed them directly in our program. The best is of course the loading
- the resource file from the external file. This has several advantages:
- the resource can be translated to another languages without your involvement
- (and hacking your program to pieces), the resource isn't included each time you
- compile the program (time is a precious thing), the adding new features is much
- easier (you include the new feature and you add some code into you program to
- detect this new RSC feature).
-
- AES initialisation
-
- Firstly we are calling appl_init() function, which returns the global
- application identifier. If appl_init() returns -1 then AES cannot be used and
- we must terminate the program.
- If this condition not occured then we can read from the global array and get
- some information about the system with app_getinfo().
- If appl_init() worked ok then we can use graf_handle() function (the info about
- the size of system fonts - it returns id of screen, which is needed to
- initialise the VDI).
-
- VDI initialisation
-
- We are initialising VDI with v_opnvwk(), which needs as an input an array
- (called WORK_IN further in this article) with some settings and another array
- (called WORK_OUT) for holding the returned values. Moreover v_opnvwk() returns
- the handle which is needed to displaying graphics and text on the screen. This
- number is set in the beginning on the value returned by graf_handle(), but
- after calling of earlier mentioned function, it's value is changing (after that
- it holds handle of VDI workstation). Because AES handle can be helpful in the
- future (it holds handle of physical screen), it's wise to store it somewhere
- (separate variable).
- WARNING! This function opens virtual workstation (that's because the system
- needs the screen make it accessible to another applications and filters every
- output). For example during printing document via printer, the GDOS opens
- printer as a workstation (with v_opnvwk()), that's because two applications
- cannot print simultanously.
-
- The content of arrays WORK_IN and WORK_OUT are containing informations for
- example how many coulours can be displayed/printed by device and which system
- drawing functions can be used (more about it later) and much more.
- WORK_IN is important, that's because it tells if the system will be using the
- actual screen coordinates or normalized device coordinates (NDC). The NDC
- system treats the screen as a device which can display 32767*32767 points. This
- means, that no matter what resolution we have, the square 16384*16384 will be
- always covering the 1/4 of the screen area. This system is very useful with
- creating WYSIWYG (What You See Is What You Get) applications. The same
- coordinates can be used for screen and printer for example. GEM manages scaling
- (on the output) pretty well, but scaling ratio isn't handled at all.
-
- Next function used during VDI initialisation is vq_extend(). This one returns
- further informations about the device with given VDI handle.
- If v_opnvwk() returns 0, we can't use VDI at all, something went wrong and we
- must quit immadiately. We can possibly show the dialog window with error number
- that informs the user about VDI non-availability and possible cause.
-
- Loading the resource file
-
- The resource file is that part of our program, which presents itself to the
- user. This is a set of standard structures which are defined in AES.H header
- file and are called OBJECTS. Each dialog box is an object, equally as menu.
- Each resource file can have several types of objects.
- To include resource file in our program we simply call rsrc_load() function. As
- parameters we give the name of our rsc file(NULL terminated string).
- Function returns 0 if RSC file wasn't found (it isn't in the current directory
- with the executable). We can of course give the full path and specify another
- storing place of resource file, but it is very unpractical and it can make
- problems with installation of your application.
- Good practice is to give the resource file the same name as in executable file.
- The function performs all the needed memory allocation and if everything was ok
- it should return the pointer to the beginning RSC tree structure.
-
- Freeing the resource file
-
- We are releasing the previously loaded RSC file with rsrc_free() function. It
- returns 0 if the allocated memory cannot be freed (tell about it to the
- application user !).
-
- Closing of the VDI workstation
-
- We are calling v_clsvwk() with VDI handle returned in the beginning by
- v_opnvwk() passed as a parameter.
-
- Exit the application
-
- Use appl_exit(). That's all !
-
- This is basically what should perform every GEM application. If you are lucky
- you should at this stage see a green (or another) desktop and quit gracefully.
- Now we are ready to do...
-
- <link=art52b.scr>Go to PART #2</l>
- </frame>
- </body>
-
-