]> git.sur5r.net Git - cc65/blobdiff - samples/multidemo.c
Removed a "cc65_" prefix.
[cc65] / samples / multidemo.c
index 367ce39e1e936b987f4cd72f9e59a458889df430..396d7344a1b6dfacd9348e3052a5b6314006aeb4 100644 (file)
@@ -1,30 +1,34 @@
 /*
- * Extended memory overlay demo program.
- *
- * 2012-17-07, Oliver Schmidt (ol.sc@web.de)
- *
- */
+** Extended memory overlay demo program.
+**
+** Shows how to combine multiple cc65 features
+** incl. overlays and extended memory drivers.
+**
+** 2012-17-07, Oliver Schmidt (ol.sc@web.de)
+**
+*/
 
 
 
 #include <string.h>
-#include <conio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <dirent.h>
 #include <em.h>
+#include <cc65.h>
 #ifndef __CBM__
 #include <fcntl.h>
 #include <unistd.h>
 #else
+#include <cbm.h>
 #include <device.h>
 #endif
 
 
 /* The symbols _OVERLAY?_LOAD__ and _OVERLAY?_SIZE__ were generated by the
- * linker. They contain the overlay area address and size specific to a
- * certain program.
- */
+** linker. They contain the overlay area address and size specific to a
+** certain program.
+*/
 extern void _OVERLAY1_LOAD__[], _OVERLAY1_SIZE__[];
 extern void _OVERLAY2_LOAD__[], _OVERLAY2_SIZE__[];
 extern void _OVERLAY3_LOAD__[], _OVERLAY3_SIZE__[];
@@ -42,24 +46,24 @@ struct {
 
 
 /* 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.
- */
+** 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)
 {
     /* 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.
-     */
+    ** 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.
+    */
     printf ("Log: %s\n", msg);
 }
 
 
 /* In a real-world overlay program one would probably not use a #pragma but
- * rather place all the code of certain source files into the overlay by
- * compiling them with --code-name OVERLAY1.
- */
+** rather place 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)
@@ -226,21 +230,21 @@ void main (void)
     }
 
     log ("Press any key...");
-    cgetc ();
+    getchar ();
 
     if (loadoverlay (1)) {
         log ("Calling overlay 1 from main");
 
         /* 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.
-         */
+        ** addr. However it's up to user to make sure that the - right - overlay
+        ** is actually loaded before making the the call.
+        */
         foo ();
     }
 
     /* Replacing one overlay with another one can only happen from the main
-     * program. This implies that an overlay can never load another overlay.
-     */
+    ** program. This implies that an overlay can never load another overlay.
+    */
     if (loadoverlay (2)) {
         log ("Calling overlay 2 from main");
         bar ();
@@ -251,6 +255,8 @@ void main (void)
         foobar ();
     }
 
-    log ("Press any key...");
-    cgetc ();
+    if (doesclrscrafterexit ()) {
+        log ("Press any key...");
+        getchar ();
+    }
 }