Forcing data arround in ca65?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Forcing data arround in ca65?
by on (#174451)
I had noticed that with my metasprite routine, the value of the address of the metasprite is a 16 bit value, and while I certainly believe that I can fit all my metasprite information in one bank, I don't know if the assembler will put it all there. Similarly, many times, if the identity of something in a slot is 0, then it counts as the thing not existing, the address of the thing could actually start at 0, if that makes sense. Is there a way to solve these issues?
Re: Forcing data arround in ca65?
by on (#174456)
To put everything of a particular type in the same bank, make a separate SEGMENT for that bank (see ld65 Users Guide) and then put everything of that type in that .segment (see ca65 Users Guide). At what level of detail would you like one of us to describe the means of doing so?
Re: Forcing data arround in ca65?
by on (#174482)
Yeah, I have absolutely no clue how you do that. Is it just something like this?

Code:
.segment

;stuff...

.endsegmet


I'm guessing it would put it in any bank where it would fit, or do you have to specify which one?

Also, should I be concerned about this? It's part of "snes.cfg".

Code:
# ca65 linker config for 256 KiB (2 Mbit) sfc file

# Physical areas of memory
MEMORY {
  ZEROPAGE:   start =  $000000, size =  $0100;   # $0000-00ff -- zero page
                                                 # $0100-01ff -- stack
  BSS:        start =  $000200, size =  $1e00;   # $0200-1fff -- RAM
  BSS7E:      start =  $7e2000, size =  $e000;   # SNES work RAM, $7e2000-7effff
  BSS7F:      start =  $7f0000, size = $10000;   # SNES work RAM, $7f0000-$7ffff
  ROM0:       start =  $008000, size =  $8000, fill = yes;
  ROM1:       start =  $018000, size =  $8000, fill = yes;
  ROM2:       start =  $028000, size =  $8000, fill = yes;
  ROM3:       start =  $038000, size =  $8000, fill = yes;
  ROM4:       start =  $048000, size =  $8000, fill = yes;
  ROM5:       start =  $058000, size =  $8000, fill = yes;
  ROM6:       start =  $068000, size =  $8000, fill = yes;
  ROM7:       start =  $078000, size =  $8000, fill = yes;
}

# Logical areas code/data can be put into.
SEGMENTS {
  CODE:       load = ROM0, align =  $100;
  RODATA:     load = ROM0, align =  $100;
  SNESHEADER: load = ROM0, start = $ffc0;
  CODE1:      load = ROM1, align =  $100, optional = yes;
  RODATA1:    load = ROM1, align =  $100, optional = yes;
  CODE2:      load = ROM2, align =  $100, optional = yes;
  RODATA2:    load = ROM2, align =  $100, optional = yes;
  CODE3:      load = ROM3, align =  $100, optional = yes;
  RODATA3:    load = ROM3, align =  $100, optional = yes;
  CODE4:      load = ROM4, align =  $100, optional = yes;
  RODATA4:    load = ROM4, align =  $100, optional = yes;
  CODE5:      load = ROM5, align =  $100, optional = yes;
  RODATA5:    load = ROM5, align =  $100, optional = yes;
  CODE6:      load = ROM6, align =  $100, optional = yes;
  RODATA6:    load = ROM6, align =  $100, optional = yes;
  CODE7:      load = ROM7, align =  $100, optional = yes;
  RODATA7:    load = ROM7, align =  $100, optional = yes;

  ZEROPAGE:   load = ZEROPAGE, type = zp;
  BSS:        load = BSS,   type = bss, align = $100, optional = yes;
  BSS7E:      load = BSS7E, type = bss, align = $100, optional = yes;
  BSS7F:      load = BSS7F, type = bss, align = $100, optional = yes;
}
Re: Forcing data arround in ca65?
by on (#174483)
There is no .endsegment. You just have to put .segment "SOMESEGMENT" to change the current segment before the sprite layout tables, and put .segment "OTHERSEGMENT" afterward. If you want behavior like that of .proc and .endproc, use .pushseg, .segment "SOMESEGMENT", and .popseg.

With the linker configuration file you pasted, you can just use, say, .segment "RODATA6" if everything will fit in bank 6.
Re: Forcing data arround in ca65?
by on (#174492)
tepples wrote:
With the linker configuration file you pasted, you can just use, say, .segment "RODATA6" if everything will fit in bank 6.

Yeah, that's basically what I was looking for. I understand it now. I was a little confused because I thought "CODE" and "RODATA" encompassed everything, not just bank 0, and ca65 just rearranged everything to what banks the information would fit in. I didn't look at it very hard... :lol:
Re: Forcing data arround in ca65?
by on (#174538)
I just thought of something... If there are two files that are included under RODATA and there are next to each other in the .asm file, shouldn't they also be assembled next to each other?
Re: Forcing data arround in ca65?
by on (#174540)
Espozo wrote:
I just thought of something... If there are two files that are included under RODATA and there are next to each other in the .asm file, shouldn't they also be assembled next to each other?


Yeah, you can count on that. In that regard, the bytes of an included data file will be treated the same as bytes of code would be.