GEOS no longer requires explicit exit() call, now explicit MainLoop() is required
git-svn-id: svn://svn.cc65.org/cc65/trunk@1898 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -111,18 +111,13 @@ e-mail: <tt/ytm@elysium.pl/
|
|||||||
<p>
|
<p>
|
||||||
This chapter describes some rules you ought to obey, and how to use GEOSLib.
|
This chapter describes some rules you ought to obey, and how to use GEOSLib.
|
||||||
|
|
||||||
<sect1>General rules
|
<sect1>Usage
|
||||||
<p>
|
|
||||||
Think twice before you use standard C library function. In current implementation almost always
|
|
||||||
you will get better code using only <tt/geos.h/. This is constantly changing as standard
|
|
||||||
functions are becoming wrappers to native GEOS Kernal with the new releases.
|
|
||||||
<p>
|
<p>
|
||||||
Apart from this file, which merely describes only standard GEOS library functions, you should read
|
Apart from this file, which merely describes only standard GEOS library functions, you should read
|
||||||
<tt/grc/ (GEOS resource compiler) documentation. There are informations about necessary resource
|
<tt/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
|
files (each GEOS application neeeds at least one) and the building process - what should be done
|
||||||
and in which order.
|
and in what order. Please also read cc65's documentation on how to compile C, assembler and link
|
||||||
|
everything together.
|
||||||
<sect1>Usage
|
|
||||||
<p>
|
<p>
|
||||||
All in all, you just need to place
|
All in all, you just need to place
|
||||||
<tscreen><verb>
|
<tscreen><verb>
|
||||||
@@ -130,11 +125,6 @@ All in all, you just need to place
|
|||||||
</verb></tscreen>
|
</verb></tscreen>
|
||||||
on top of your source.
|
on top of your source.
|
||||||
<p>
|
<p>
|
||||||
Please read cc65's documentation on how to compile C, assembler and link everything together.
|
|
||||||
<p>
|
|
||||||
GEOSLib building process isn't yet defined stable. Detailed information how to link everything
|
|
||||||
together is in separated file together with resource compiler documentation.
|
|
||||||
<p>
|
|
||||||
As a general rule read the sources of example programs and read the headers. These are the most
|
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
|
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,
|
arguments passed to functions. Please use them. You will find your sources easier to understand,
|
||||||
@@ -146,12 +136,17 @@ Screen coordinates are given in pixels unless stated differently.
|
|||||||
|
|
||||||
<sect1>Notes on style
|
<sect1>Notes on style
|
||||||
<p>
|
<p>
|
||||||
All programs start their execution on <tt/main/ function. Unlike plain C exiting from this function
|
Contrary to typical GEOS assembly program which has a main function called after loading that
|
||||||
doesn't mean end of program. GEOS is event-driven environment where applications are only executing
|
setups the screen, menus, icons etc. exiting from <tt/main/ function in C is equivalent to
|
||||||
events, main loop is in kernal. <tt/main/ function should setup the screen, menus etc. and return.
|
calling <tt/exit()/. These two are the only safe methods of terminating applications. DO NOT
|
||||||
Real end of the program should be called from event call, e.g. from menu item. You can force end of
|
USE <tt/EnterDeskTop/! Your data may be lost as library destructors and functions registered
|
||||||
program and return to DeskTop either by standard <tt/exit (0)/ function or by <tt/EnterDeskTop()/.
|
with <tt/atexit/ will not be called.
|
||||||
Currently they are almost the same.
|
<p>
|
||||||
|
For GEOS GUI applications the recommended program structure is to have everything initialized
|
||||||
|
in <tt/main/ function and at the end of it a call to <tt/MainLoop()/ function. WARNING! This
|
||||||
|
function never returns, any code between <tt/MainLoop();/ and the end of <tt/main/ will not
|
||||||
|
be executed. You have to call <tt/exit()/ explicitly somewhere in your code (e.g. in a menu
|
||||||
|
handler or via DialogBox action).
|
||||||
<p>
|
<p>
|
||||||
Whenever possible use definitions from <tt/gsym.h/. The resulting code is translated by cc65 into
|
Whenever possible use definitions from <tt/gsym.h/. The resulting code is translated by cc65 into
|
||||||
series of <tt/lda/ and <tt/sta/, so you can't do it better :-).
|
series of <tt/lda/ and <tt/sta/, so you can't do it better :-).
|
||||||
@@ -163,7 +158,7 @@ You might wonder why I have chosen sometimes weird order of arguments in functio
|
|||||||
I wanted to avoid unnecessary pushing and popping arguments from stack. cc65 can pass single <tt/int/
|
I wanted to avoid unnecessary pushing and popping arguments from stack. cc65 can pass single <tt/int/
|
||||||
through CPU registers.
|
through CPU registers.
|
||||||
<p>
|
<p>
|
||||||
Do not try to compile in strict ANSI mode. I'm using some cc65 extensions which are not available in
|
Do not try to compile in strict ANSI mode. Library uses cc65 extensions which are not available in
|
||||||
ANSI.
|
ANSI.
|
||||||
|
|
||||||
<sect>Library Functions
|
<sect>Library Functions
|
||||||
@@ -1191,16 +1186,19 @@ do something with IO registers or call one of Kernal's routines.
|
|||||||
<p>
|
<p>
|
||||||
<tt/void MainLoop (void)/
|
<tt/void MainLoop (void)/
|
||||||
<p>
|
<p>
|
||||||
Your programs exits to MainLoop upon exiting from <tt/main/, but you might need this function in
|
Returns control to the system. Any code between call to <tt/MainLoop/ and the end of current
|
||||||
menu and icon code. When in <tt/MainLoop/ systems waits for your action - using icons, keyboard
|
function will never be executed. When in <tt/MainLoop/ systems waits for your action - using
|
||||||
or menus to force some specific action from program.
|
icons, keyboard or menus to force some specific action from program. You have to define
|
||||||
|
proper handlers before that.
|
||||||
|
|
||||||
<sect2>EnterDeskTop
|
<sect2>EnterDeskTop
|
||||||
<p>
|
<p>
|
||||||
<tt/void EnterDeskTop (void)/
|
<tt/void EnterDeskTop (void)/
|
||||||
<p>
|
<p>
|
||||||
This is default exit code of your application. It is finish of <tt/exit()/, but you may need it
|
Calling this function will instantly terminate your program and bring you back to DeskTop.
|
||||||
in other places of application.
|
WARNING! It is not an equivalent of <tt/exit()/, library destructors code and functions
|
||||||
|
registered with <tt/atexit()/ will not be called. In fact, you should always use
|
||||||
|
<tt/exit()/ instead.
|
||||||
|
|
||||||
<sect2>ToBASIC
|
<sect2>ToBASIC
|
||||||
<p>
|
<p>
|
||||||
@@ -1208,6 +1206,7 @@ in other places of application.
|
|||||||
<p>
|
<p>
|
||||||
This one is another way of finishing application - forcing GEOS to shutdown and exit to BASIC.
|
This one is another way of finishing application - forcing GEOS to shutdown and exit to BASIC.
|
||||||
I was considering whether to include it or not, but maybe someone will need it. Which is I doubt.
|
I was considering whether to include it or not, but maybe someone will need it. Which is I doubt.
|
||||||
|
It has the same dangerous features as <tt/EnterDeskTop/.
|
||||||
|
|
||||||
<sect2>Panic
|
<sect2>Panic
|
||||||
<p>
|
<p>
|
||||||
@@ -1220,7 +1219,8 @@ System error at:xxxx
|
|||||||
where <tt/xxxx/ is last known execution address (caller). By default this is bound to <tt/BRK/
|
where <tt/xxxx/ is last known execution address (caller). By default this is bound to <tt/BRK/
|
||||||
instruction, but it might be usable in debugging as kind of <tt/assert/.
|
instruction, but it might be usable in debugging as kind of <tt/assert/.
|
||||||
<p>
|
<p>
|
||||||
System is halted after call to <tt/Panic/.
|
System is halted after call to <tt/Panic/ which means that library destructors will not be
|
||||||
|
called and some data may be lost (no wonder you're panicking).
|
||||||
|
|
||||||
<sect2>CallRoutine
|
<sect2>CallRoutine
|
||||||
<p>
|
<p>
|
||||||
@@ -1228,14 +1228,15 @@ System is halted after call to <tt/Panic/.
|
|||||||
<p>
|
<p>
|
||||||
This is system caller routine. You need to provide pointer to a function and it will be immediately
|
This is system caller routine. You need to provide pointer to a function and it will be immediately
|
||||||
called, unless the pointer is equal to <tt/NULL/. This is the main functionality of this function -
|
called, unless the pointer is equal to <tt/NULL/. This is the main functionality of this function -
|
||||||
you need not to worry if the pointer is valid.
|
you don't need to check if the pointer is valid.
|
||||||
|
|
||||||
<sect2>GetSerialNumber
|
<sect2>GetSerialNumber
|
||||||
<p>
|
<p>
|
||||||
<tt/int GetSerialNumber (void)/
|
<tt/int GetSerialNumber (void)/
|
||||||
<p>
|
<p>
|
||||||
This function returns the serial number of system. It might be used for copy-protection, but you
|
This function returns the serial number of system. It might be used for copy-protection.
|
||||||
shouldn't do this. Please remember that the Free Software is a true power.
|
However, please remember that the Free Software is a true power and you are using it
|
||||||
|
right now.
|
||||||
|
|
||||||
<sect2>GetRandom
|
<sect2>GetRandom
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -54,7 +54,6 @@
|
|||||||
cli
|
cli
|
||||||
ldy #4 ; Argument size
|
ldy #4 ; Argument size
|
||||||
jsr _main ; call the users code
|
jsr _main ; call the users code
|
||||||
jmp _MainLoop ; jump to GEOS MainLoop
|
|
||||||
|
|
||||||
; Call module destructors. This is also the _exit entry which must be called
|
; Call module destructors. This is also the _exit entry which must be called
|
||||||
; explicitly by the code.
|
; explicitly by the code.
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
;
|
;
|
||||||
; Maciej 'YTM/Alliance' Witkowiak
|
; Maciej 'YTM/Elysium' Witkowiak
|
||||||
;
|
;
|
||||||
; 30.10.99
|
; 30.10.1999, 10.01.2003
|
||||||
|
|
||||||
; void MainLoop (void);
|
; void MainLoop (void);
|
||||||
|
|
||||||
@@ -10,4 +10,5 @@
|
|||||||
|
|
||||||
.include "../inc/jumptab.inc"
|
.include "../inc/jumptab.inc"
|
||||||
|
|
||||||
_MainLoop = MainLoop
|
_MainLoop:
|
||||||
|
jmp MainLoop
|
||||||
|
|||||||
Reference in New Issue
Block a user