This chapter describes some rules you ought to obey, and how to use GEOSLib.
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 needs at least one) and the building process - what should be done
and in what order. Please also read cc65's documentation on how to compile C, assembler and link
everything together.
All in all, you just need to place
#include <geos.h>
on top of your source.
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.
Contrary to typical GEOS assembly program which has a main function called after loading that
setups the screen, menus, icons etc. exiting from main
function in C is equivalent to
calling exit()
. These two are the only safe methods of terminating applications. DO NOT
USE EnterDeskTop
! Your data may be lost as library destructors and functions registered
with atexit
will not be called.
For GEOS GUI applications the recommended program structure is to have everything initialized
in main
function and at the end of it a call to MainLoop()
function. WARNING! This
function never returns, any code between MainLoop();
and the end of main
will not
be executed. You have to call exit()
explicitly somewhere in your code (e.g. in a menu
handler or via DialogBox action).
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
.
The main
function receives the standard argc
and argv
parameters. There are
always either 1 or 3 parameters. DOS application name is always set as argv[0]
.
If present, argv[1]
and argv[2]
will be set to data filename and data diskname (it only
works if user double-clicks on data file associated with your application). Note that it is up
to your application to determine which of the available (up to four) disk drives has the disk
with given diskname inside. If this fails your program should ask to insert the proper disk into
one of available drives.
You might wonder why I have chosen sometimes weird order of arguments in functions. I just
wanted to avoid unnecessary pushing and popping arguments from stack because cc65 can pass single
unsigned int
through CPU registers.
Do not try to compile in strict ANSI mode. Library uses cc65 extensions which are not available in ANSI.
It is possible to use dynamically loaded modules, three such modules are provided: GEOS TGI driver, GEOS EMD driver (for VDC extended memory) and GEOS JOY driver. Just make sure that their filenames appear UPPERCASE in DeskTop. There are no more special recommendations, read cc65 documentation about modules and demo programs source code.