Re: [cc65] Specific Memory Addresses at Compilation

From: Marc 'BlackJack' Rintsch <marc1rintsch.de>
Date: 2012-10-23 15:49:07
On Tuesday 23 October 2012 14:29:16 Zen Tom wrote:
> 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.

Why don't you want to use an assembler file alongside the raw data file?  
That's the simplest way to do it with ld65 AFAIK.  Suppose your file is named 
``sprites.dat`` and is saved on a C64 with a monitor, i.e. two address bytes 
and the contents from $4000 to $8000, then you define a segment in the linker 
config, let's say `sprite_data` that goes into the `RAWDATA` memory region you 
defined above.  All you need now is an assembler file like::

  .segment "sprite_data"
  .incbin "sprites.dat", 2  ; <- Skip the two bytes load address.

This turns the sprite data into an object file suitable for the linker.  

I thought placing binaries at some fixed address should be a FAQ — and it 
turns out it *is* one: http://www.cc65.org/faq.php#ORG  :-)

Another solution might me just reserving the space with a linker config and 
use some other program to combine the final binary with the sprite data.  It 
may be possible to use a compression program like ``exomizer`` for this.  
Assuming the above mentioned files the command line looks like this::

  exomizer sfx sys program.prg sprites.dat -o crunched.prg

Ciao,
		Marc 'BlackJack' Rintsch
----------------------------------------------------------------------
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 15:49:23 2012

This archive was generated by hypermail 2.1.8 : 2012-10-23 15:49:26 CEST