Next Previous Contents

2. What have you got and what to do with it?

This chapter describes some rules you ought to obey, and how to use GEOSLib.

2.1 General rules

Think twice before you use standard C library function. In current implementation almost always you will get better code using only geos.h. This is constantly changing as standard functions are becoming wrappers to native GEOS Kernal with the new releases.

Apart from this file, which merely describes only standard GEOS library functions, you should read grc (GEOS resource compiler) documentation. There are informations about necessary resource files (each GEOS application neeeds at least one) and the building process - what should be done and in which order.

2.2 Usage

All in all, you just need to place

#include <geos.h>
on top of your source.

Please read cc65's documentation on how to compile C, assembler and link everything together.

GEOSLib building process isn't yet defined stable. Detailed information how to link everything together is in separated file together with resource compiler documentation.

As a general rule read the sources of example programs and read the headers. These are the most reliable sources of knowledge ;). You will also find there many C macros representing various arguments passed to functions. Please use them. You will find your sources easier to understand, and it will be easier to find bugs.

All types used in GEOSLib are unsigned.

Screen coordinates are given in pixels unless stated differently.

2.3 Notes on style

All programs start their execution on main function. Unlike plain C exiting from this function doesn't mean end of program. GEOS is event-driven environment where applications are only executing events, main loop is in kernal. main function should setup the screen, menus etc. and return. Real end of the program should be called from event call, e.g. from menu item. You can force end of program and return to DeskTop either by standard exit (0) function or by EnterDeskTop(). Currently they are almost the same.

Whenever possible use definitions from gsym.h. The resulting code is translated by cc65 into series of lda and sta, so you can't do it better :-).

Don't hesitate to use library functions. Everything was written with size and speed in mind. In fact many calls are just redirections to GEOS kernal which results in simple jsr.

You might wonder why I have chosen sometimes weird order of arguments in functions. It is because I wanted to avoid unnecessary pushing and popping arguments from stack. cc65 can pass single int through CPU registers.

Do not try to compile in strict ANSI mode. I'm using some cc65 extensions which are not available in ANSI.


Next Previous Contents