]> git.sur5r.net Git - cc65/blobdiff - samples/overlaydemo.c
Keep git push happy.
[cc65] / samples / overlaydemo.c
index 70a35f11d99fd13131895011417eebc4ab5d54d3..a3fb132e1de650e1f01ceaba20aa6033472910b5 100644 (file)
@@ -9,8 +9,12 @@
 
 #include <stdio.h>
 #include <conio.h>
+#ifndef __CBM__
 #include <fcntl.h>
 #include <unistd.h>
+#else
+#include <device.h>
+#endif
 
 
 extern void _OVERLAY1_LOAD__[], _OVERLAY1_SIZE__[];
@@ -29,7 +33,7 @@ void log (char *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
+ * rather place all the code of certain source files into the overlay by
  * compiling them with --code-name OVERLAY1.
  */
 #pragma code-name (push, "OVERLAY1");
@@ -69,14 +73,26 @@ void foobar (void)
 
 unsigned char loadfile (char *name, void *addr, void *size)
 {
+#ifndef __CBM__
+
     int file = open (name, O_RDONLY);
     if (file == -1) {
         log ("Opening overlay file failed");
         return 0;
     }
-
     read (file, addr, (unsigned) size);
     close (file);
+
+#else
+
+    /* Avoid compiler warnings about unused parameters. */
+    (void) addr; (void) size;
+    if (cbm_load (name, getcurrentdevice (), NULL) == 0) {
+        log ("Loading overlay file failed");
+        return 0;
+    }
+
+#endif
     return 1;
 }