Added secondary linker config for C64 overlays (incl. demo program).
git-svn-id: svn://svn.cc65.org/cc65/trunk@5679 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -122,6 +122,9 @@ endif
|
||||
|
||||
nachtm: nachtm.o
|
||||
|
||||
overlaydemo: overlaydemo.o
|
||||
@$(LD) -t $(SYS) -m $(basename $@).map -C $(SYS)-overlay.cfg -o $@ $^ $(CLIB)
|
||||
|
||||
plasma: plasma.o
|
||||
|
||||
sieve: sieve.o
|
||||
|
||||
86
samples/overlaydemo.c
Normal file
86
samples/overlaydemo.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Minimalistic overlay demo program.
|
||||
*
|
||||
* 2009-10-02, Oliver Schmidt (ol.sc@web.de)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
extern void _OVERLAY1_LOAD__, _OVERLAY1_SIZE__;
|
||||
extern void _OVERLAY2_LOAD__, _OVERLAY2_SIZE__;
|
||||
extern void _OVERLAY3_LOAD__, _OVERLAY3_SIZE__;
|
||||
|
||||
|
||||
void log (char *msg)
|
||||
{
|
||||
printf ("Log: %s\n", msg);
|
||||
}
|
||||
|
||||
|
||||
#pragma code-name (push, "OVERLAY1");
|
||||
|
||||
void foo (void)
|
||||
{
|
||||
log ("Calling main from overlay 1");
|
||||
}
|
||||
|
||||
#pragma code-name (pop);
|
||||
|
||||
|
||||
#pragma code-name (push, "OVERLAY2");
|
||||
|
||||
void bar (void)
|
||||
{
|
||||
log ("Calling main from overlay 2");
|
||||
}
|
||||
|
||||
#pragma code-name (pop);
|
||||
|
||||
|
||||
#pragma code-name (push, "OVERLAY3");
|
||||
|
||||
void foobar (void)
|
||||
{
|
||||
log ("Calling main from overlay 3");
|
||||
}
|
||||
|
||||
#pragma code-name(pop);
|
||||
|
||||
|
||||
unsigned char loadfile (char *name, void *addr, void *size)
|
||||
{
|
||||
int file = open (name, O_RDONLY);
|
||||
if (file == -1) {
|
||||
log ("Opening overlay file failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
read (file, addr, (unsigned) size);
|
||||
close (file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void main (void)
|
||||
{
|
||||
log ("Calling overlay 1 from main");
|
||||
if (loadfile ("overlaydemo.1", &_OVERLAY1_LOAD__, &_OVERLAY1_SIZE__)) {
|
||||
foo ();
|
||||
}
|
||||
|
||||
log ("Calling overlay 2 from main");
|
||||
if (loadfile ("overlaydemo.2", &_OVERLAY2_LOAD__, &_OVERLAY2_SIZE__)) {
|
||||
bar ();
|
||||
}
|
||||
|
||||
log ("Calling overlay 3 from main");
|
||||
if (loadfile ("overlaydemo.3", &_OVERLAY3_LOAD__, &_OVERLAY3_SIZE__)) {
|
||||
foobar ();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user