#
# FastBasic - Fast basic interpreter for the Atari 8-bit computers
# Copyright (C) 2017-2019 Daniel Serpell
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>
#

# Linker configuration file for placing the code in a CARTRIDGE
# -------------------------------------------------------------

FEATURES {
    # This defines the start of RAM used for the program
    STARTADDRESS: default = $2000;
}
SYMBOLS {
    __STARTADDRESS__: type = export, value = %S;
    __CARTFLAGS__:    type = weak,   value = $05;
    _FASTBASIC_CART_: type = import;
}

MEMORY {
# Interpreter in ZP
    INTERP:  file = "",               start = $0082, size = $0012;
# Non initialized ZP
    ZP:      file = "", define = yes, start = $0094, size = $0040;
# Main memory - used for writable DATA
    MAIN:    file = "", define = yes, start = %S,    size = $8000;
# Cartridge ROM
    ROM:     file = %O, define = yes, start = $A000, size = $1FFA, fill = yes, fillval = $FF;
# Cartridge header
    CARTID:  file = %O,               start = $BFFA, size = 6;
}

SEGMENTS {
    ZEROPAGE: load = ZP,                type = zp,  optional = yes;
    JUMPTAB:  load = ROM,               type = ro,                  define = yes, align = $100;
    RUNTIME:  load = ROM,               type = ro,                  define = yes;
    BYTECODE: load = ROM,               type = ro,                  define = yes;
    CODE:     load = ROM,               type = rw,                  define = yes;
    INTERP:   load = ROM, run = INTERP, type = rw,                  define = yes;
    RT_DATA:  load = ROM, run = MAIN,   type = rw,                  define = yes;
    DATA:     load = ROM, run = MAIN    type = rw,  optional = yes, define = yes;
    BSS:      load = MAIN,              type = bss, optional = yes, define = yes;
    CARTHDR:  load = CARTID,            type = ro;
}

