2 * Minimalistic GEOSLib overlay demo program
4 * 2012-01-01, Oliver Schmidt (ol.sc@web.de)
11 #include "overlay-demores.h"
14 /* Functions resident in an overlay can call back functions resident in the
15 * main program at any time without any precautions. The function show() is
16 * an example for such a function resident in the main program.
22 sprintf(line1, CBOLDON "Overlay Demo - Overlay %s" CPLAINTEXT, name);
24 "Click OK to return to Main.");
27 /* In a real-world overlay program one would probably not use a #pragma but
28 * rather place the all the code of certain souce files into the overlay by
29 * compiling them with --code-name OVERLAY1.
31 #pragma code-name(push, "OVERLAY1");
35 /* Functions resident in an overlay can access all program variables and
36 * constants at any time without any precautions because those are never
37 * placed in overlays. The string constant "One" is an example for such
38 * a constant resident in the main program.
43 #pragma code-name(pop);
46 #pragma code-name(push, "OVERLAY2");
53 #pragma code-name(pop);
56 #pragma code-name(push, "OVERLAY3");
63 #pragma code-name(pop);
66 void main(int /*argc*/, char *argv[])
68 if (OpenRecordFile(argv[0])) {
69 _poserror("OpenRecordFile");
73 DlgBoxOk(CBOLDON "Overlay Demo - Main" CPLAINTEXT,
74 "Click OK to call Overlay One.");
77 _poserror("PointRecord.1");
81 /* The macro definitions OVERLAY_ADDR and OVERLAY_SIZE were generated in
82 * overlay-demores.h by grc65. They contain the overlay area address and
83 * size specific to a certain program.
85 if (ReadRecord(OVERLAY_ADDR, OVERLAY_SIZE)) {
86 _poserror("ReadRecord.1");
90 /* The linker makes sure that the call to foo() ends up at the right mem
91 * addr. However it's up to user to make sure that the - right - overlay
92 * is actually loaded before making the the call.
96 DlgBoxOk(CBOLDON "Overlay Demo - Main" CPLAINTEXT,
97 "Click OK to call Overlay Two.");
100 _poserror("PointRecord.2");
104 /* Replacing one overlay with another one can only happen from the main
105 * program. This implies that an overlay can never load another overlay.
107 if (ReadRecord(OVERLAY_ADDR, OVERLAY_SIZE)) {
108 _poserror("ReadRecord.2");
114 DlgBoxOk(CBOLDON "Overlay Demo - Main" CPLAINTEXT,
115 "Click OK to call Overlay Three.");
117 if (PointRecord(3)) {
118 _poserror("PointRecord.3");
122 if (ReadRecord(OVERLAY_ADDR, OVERLAY_SIZE)) {
123 _poserror("ReadRecord.3");
129 if (CloseRecordFile()) {
130 _poserror("CloseRecordFile");