Re: [cc65] Specific Memory Addresses at Compilation

From: Zen Tom <zentom1gmail.com>
Date: 2012-10-23 14:29:16
OK, I've been rethinking this:

The natural way to do what I want would be to generate a raw data file
"data.raw" containing my data and be able to place that at compile/linking
time into a specific address.

So for example - what I'd like to do is to use an assembler/memory monitor
to curate the data I want between $4000 and $8000 into a raw data file.
That's traditional C64 coding practice and well documented around the place.

Once my raw data is set, I want to be able to specify a reserved memory
area in my config.cfg file

e.g:

MEMORY {
    ZP:  start = $0002, size = $001A, type = rw, define = yes;
    RAM:  start = $07FF, size = $3800, file = %O, define = yes;
    RAWDATA: start = $4000, size = $3FFF, file = %O, define = yes;
    RAM2: start = $8000, size = $4FFF, file = %O, define = yes;
}

Next, what I want the linker to do is to load up the raw data file I've
saved down in data.raw and load it into the RAWDATA memory location
specified in the config file?

It seems there's a method for doing this using an assembler file - but
that's not what I want to do - I just want to be able to do a "binary load"
type operation, from raw into a preset location - like in an old machine
code monitor - obviously I need to reserve that space so no program code is
placed in there, which is why I'm guessing this is something that would use
the linker cfg file to organise.

Is this something I can do with the current assembler/linker/compiler code,
or do I need to write myself a routine to do this at runtime? The downside
being that in writing a runtime routine, I need to write different code for
different i/o devices etc (tape, disk etc) and for now for convenience I'd
like to be able to pre-load my data at compile time.

Any thoughts on achieving the above?

If I can't load the raw data directly - then the second option is to mirror
that raw data in an array, but I need to specify to the compiler that I
want that data in very specific/inviolate memory location. One way of doing
that would be to do something like:

typedef byte SpriteData[190][64]; /* I've got 190 sprites each of which
take up 64 bytes */

#define Sprites  (*(SpriteData*)0x4800)

then define my data elsewhere in an array, and read that data into the
location defined above.

But I'm not convinced that

a) 0x4800 to 0x8000 is reserved by the linker

b) I don't want to have to store my data twice - once in some random
location, from where I will have to read it and copy it to where I want it
to reside.

The reason for all this nonsense is that I want to try and use the hardware
sprite capabilities of the C64, but they require certain data structures to
be placed at particular locations in the RAM,

Kind regards,
Tom

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Oct 23 14:29:32 2012

This archive was generated by hypermail 2.1.8 : 2012-10-23 14:29:35 CEST