# On the Apple2 the overlays are placed below the main program

# The overlay files don't include the 4 byte DOS 3.3 header so use AppleCommander like this:
# java -jar ac.jar -cc65 prodos.dsk overlaydemo   bin < overlaydemo
# java -jar ac.jar -p    prodos.dsk overlaydemo.1 bin < overlaydemo.1
# java -jar ac.jar -p    prodos.dsk overlaydemo.2 bin < overlaydemo.2
# java -jar ac.jar -p    prodos.dsk overlaydemo.3 bin < overlaydemo.3

SYMBOLS {
    OVERLAYSIZE: value = $1000, weak = yes;
}
MEMORY {
    ZP:     start = $0080,               size = $001A,                          define = yes;
    HEADER: start = $0000,               size = $0004,               file = %O;
    RAM:    start = $0803 + OVERLAYSIZE, size = $8DFD - OVERLAYSIZE, file = %O, define = yes;
    OVL1:   start = $0803,               size = OVERLAYSIZE,         file = "overlaydemo.1";
    OVL2:   start = $0803,               size = OVERLAYSIZE,         file = "overlaydemo.2";
    OVL3:   start = $0803,               size = OVERLAYSIZE,         file = "overlaydemo.3";
    MOVE:   start = $0000,               size = $FFFF,               file = %O, define = yes;
    LC:     start = $D400,               size = $0C00,                          define = yes;
}
SEGMENTS {
    ZEROPAGE: load = ZP,              type = zp;
    EXEHDR:   load = HEADER,          type = ro;
    STARTUP:  load = RAM,             type = ro;
    LOWCODE:  load = RAM,             type = ro;
    CODE:     load = RAM,             type = ro;
    OVL1CODE: load = OVL1,            type = ro,  define   = yes;
    OVL2CODE: load = OVL2,            type = ro,  define   = yes;
    OVL3CODE: load = OVL3,            type = ro,  define   = yes;
    RODATA:   load = RAM,             type = ro;
    DATA:     load = RAM,             type = rw;
    ZPSAVE:   load = RAM,             type = bss, define   = yes;
    BSS:      load = RAM,             type = bss, define   = yes;
    INIT:     load = MOVE, run = RAM, type = ro,  define   = yes;
    HIGHCODE: load = MOVE, run = LC,  type = ro,  optional = yes;
}
FEATURES {
    CONDES: segment = INIT,
            type    = constructor,
            label   = __CONSTRUCTOR_TABLE__,
            count   = __CONSTRUCTOR_COUNT__;
    CONDES: segment = RODATA,
            type    = destructor,
            label   = __DESTRUCTOR_TABLE__,
            count   = __DESTRUCTOR_COUNT__;
    CONDES: type    = interruptor,
            segment = RODATA,
            label   = __INTERRUPTOR_TABLE__,
            count   = __INTERRUPTOR_COUNT__;
}
SYMBOLS {
    __STACKSIZE__: value = $0800, weak = yes; # 2k stack
}
