Re: [cc65] overlapping segments, segment groups?

From: MagerValp <MagerValp1cling.gu.se>
Date: 2006-04-28 09:21:48
>>>>> "UvB" == Ullrich von Bassewitz <uz@musoftware.de> writes:

UvB> I have to admit that I don't have a good idea how to add overlaid
UvB> segments, or a simliar feature in a clean manner. If anybody has
UvB> suggestions, I would like to hear them.

How about segment overlays?

MEMORY {
    LOADERZP: start = $57, size = 2, type = rw;
    ZP: start = $59, size = 2, type = rw;
    RAM: start = $07ff, size = $c801, file = %O;
    DRIVECODE: start = $0300, size = $0400;
}

SEGMENTS {
    STARTUP: load = RAM, type = ro;
    CODE: load = RAM, type = ro;
    RODATA: load = RAM, type = ro;
    DATA: load = RAM, type = rw;
    DRIVESTART: load = RAM, run = DRIVECODE, type = rw, define = yes, align = $0100;
    OVERLAY {
	FASTLOADER: load = RAM, run = DRIVECODE, type = rw, define = yes;
	D64READER: load = RAM, run = DRIVECODE, type = rw, define = yes;
	FASTFORMATTER: load = RAM, run = DRIVECODE, type = rw, define = yes;
    }
    DRIVEXFER: load = RAM, run = DRIVECODE, type = rw, define = yes;
    BSS: load = RAM, type = bss, define = yes, align = $0100;
    LOADERZP: load = LOADERZP, type = zp;
    ZEROPAGE: load = ZP, type = zp;
}

The size of the overlay would be that of the largest overlay segment.
Hmm, another crazy thought - maybe nested overlays would be useful? If
you only need a particular piece of code when the program starts, like
drive code that gets sent over to the drive, or some graphics that's
moved up into $e000 under the roms, you could overlay it with the bss
segment. You could of course not use any BSS variables before the
segments have been moved out of the way, but this could easily be done
with ZP only, or just put them in the STARTUP segment for that matter.
Some kind of grouping would be needed as well, but you could (ab)use
the SEGMENTS for that:

SEGMENTS {
    STARTUP: load = RAM, type = ro;
    CODE: load = RAM, type = ro;
    RODATA: load = RAM, type = ro;
    DATA: load = RAM, type = rw;
    OVERLAY {
	SEGMENTS {
	    DRIVESTART: load = RAM, run = DRIVECODE, type = rw, define = yes, align = $0100;
	    OVERLAY {
		FASTLOADER: load = RAM, run = DRIVECODE, type = rw, define = yes;
		D64READER: load = RAM, run = DRIVECODE, type = rw, define = yes;
		FASTFORMATTER: load = RAM, run = DRIVECODE, type = rw, define = yes;
	    }
	    DRIVEXFER: load = RAM, run = DRIVECODE, type = rw, define = yes;
	}
	BSS: load = RAM, type = bss, define = yes, align = $0100;
    }
    LOADERZP: load = LOADERZP, type = zp;
    ZEROPAGE: load = ZP, type = zp;
}

This won't really work though... :/ There's an ambiguity as to whether
the load or run segment should be overlaid. Maybe the OVERLAY needs
some attributes of its own?

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .  Per Olofsson, arkadspelare
    o-o    .      .     .   o         +          MagerValp@cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Apr 28 09:21:57 2006

This archive was generated by hypermail 2.1.8 : 2006-04-28 09:22:00 CEST