[cc65] Relocating RODATA

From: Stefan Wessels <swessels1email.com>
Date: 2011-04-23 18:45:39

I am having trouble relocating the RODATA segment.  In my generated code, the __RODATA_RUN__ and __RODATA_LOAD__ end up having the same address which can't be right.

I am making a game and I want to use the VIC pointing at bank 2 ($4000).  For this to work, I must split the RAM.  My config has these definitions in MEMORY:
  RAM2:     file = %O, 			   start = $080d, size = $39b2;
  RAM:      file = %O, define = yes, start = $8000, size = $5000 - __STACKSIZE__;

I have this line in SEGMENTS:
  RODATA:   load = RAM,      type = ro, define = yes;

The line I compile with looks like this:
cl65 -t c64 -m Snake.prg.map -o Snake.prg globals.c plat.c render.c game.c frontend.c main.c crt0.s -C snakec64.cfg

The program runs, but the opening front end screen is supposed to show text, and that text isn't there (but the game itself runs fine).  If I don't use the custom crt0.s & cfg file, everything works as expected (not a bug in my code that the text isn't there ;)

I made a copy of the standard crt0.s file and added the following:
.import		__RODATA_LOAD__, __RODATA_RUN__, __RODATA_SIZE__	; Linker generated
The code to move the RODATA starts like this (Added right after jsr zerobss):
	lda	#<__RODATA_RUN__
	sta	ptr1
	lda	#>__RODATA_RUN__
	sta	ptr1+1
	lda #<__RODATA_LOAD__
	sta ptr2
	lda #>__RODATA_LOAD__
	sta ptr2+1

The code that's generated starts like this:
.C:0823   A9 00      LDA #$00
.C:0825   85 0A      STA $0A
.C:0827   A9 80      LDA #$80
.C:0829   85 0B      STA $0B
.C:082b   A9 00      LDA #$00
.C:082d   85 0C      STA $0C
.C:082f   A9 80      LDA #$80
.C:0831   85 0D      STA $0D

Notice that __RODATA_LOAD__ and __RODATA_RUN__ both came out to be $8000.  I see the text at around $3a00 (somewhere around there is where I would think _RODATA_LOAD would be).  The Snake.prg file is 14818 bytes meaning it didn't load past 0x41E3 so something went wrong.

Anyone see where I went wrong, or is the problem somewhere else?

Thank you

To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Apr 23 18:50:58 2011

This archive was generated by hypermail 2.1.8 : 2011-04-23 18:51:01 CEST