mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Retrofitted comments from GEOS overlay demo to regular overlay demo.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5789 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
6345c4ee25
commit
3ce61b47a9
@ -18,16 +18,29 @@ extern void _OVERLAY2_LOAD__, _OVERLAY2_SIZE__;
|
||||
extern void _OVERLAY3_LOAD__, _OVERLAY3_SIZE__;
|
||||
|
||||
|
||||
/* Functions resident in an overlay can call back functions resident in the
|
||||
* main program at any time without any precautions. The function log() is
|
||||
* an example for such a function resident in the main program.
|
||||
*/
|
||||
void log (char *msg)
|
||||
{
|
||||
printf ("Log: %s\n", msg);
|
||||
}
|
||||
|
||||
|
||||
/* In a real-world overlay program one would probably not use a #pragma but
|
||||
* rather place the all the code of certain source files into the overlay by
|
||||
* compiling them with --code-name OVERLAY1.
|
||||
*/
|
||||
#pragma code-name (push, "OVERLAY1");
|
||||
|
||||
void foo (void)
|
||||
{
|
||||
/* Functions resident in an overlay can access all program variables and
|
||||
* constants at any time without any precautions because those are never
|
||||
* placed in overlays. The string constant below is an example for such
|
||||
* a constant resident in the main program.
|
||||
*/
|
||||
log ("Calling main from overlay 1");
|
||||
}
|
||||
|
||||
@ -71,11 +84,25 @@ unsigned char loadfile (char *name, void *addr, void *size)
|
||||
void main (void)
|
||||
{
|
||||
log ("Calling overlay 1 from main");
|
||||
|
||||
/* The symbols _OVERLAY1_LOAD__ and _OVERLAY1_SIZE__ were generated by the
|
||||
* linker. They contain the overlay area address and size specific to a
|
||||
* certain program.
|
||||
*/
|
||||
if (loadfile ("ovrldemo.1", &_OVERLAY1_LOAD__, &_OVERLAY1_SIZE__)) {
|
||||
|
||||
/* The linker makes sure that the call to foo() ends up at the right mem
|
||||
* addr. However it's up to user to make sure that the - right - overlay
|
||||
* is actually loaded before making the the call.
|
||||
*/
|
||||
foo ();
|
||||
}
|
||||
|
||||
log ("Calling overlay 2 from main");
|
||||
|
||||
/* Replacing one overlay with another one can only happen from the main
|
||||
* program. This implies that an overlay can never load another overlay.
|
||||
*/
|
||||
if (loadfile ("ovrldemo.2", &_OVERLAY2_LOAD__, &_OVERLAY2_SIZE__)) {
|
||||
bar ();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user