Page 1 of 1
Posted: Wed Mar 28, 2007 7:58 pm
by beneficii
I'm sorry, do you mean cC65, instead of cA65?
Hmm, those might be useful to try out then. Thanks. ^_^
EDIT: it would seem that the author of the programs doesn't really distinguish between CC65 and CA65 well. Anyway, I'm reading through the users' guide for ca65 (which I got through a search engine--I'm not sure how you can get to the users' guide from the main cc65.org page):
http://www.cc65.org/doc/ca65.html
I'm looking at the control commands and I see the ability to write bytes and words, etc., but I still don't see how I can have empty space that I don't have to put each byte for. For example:
I have a field of code/data that ends at $F656 and between this and the start of the vector data at $FFFA there is nothing to put (empty space). As there does not seem to be a simple .FILL control command in the assembler, what would be the most efficient way to put this empty space?
Posted: Wed Mar 28, 2007 8:01 pm
by tepples
Yes, CA65 is a term that some of us use to refer to the CC65 toolchain without the C compiler component. In addition to being the only non-
free component in the toolchain, CC65 could never optimize well, so most of us head straight for the assembler.
To make a block of empty space, use the
.res command. If the fill value isn't specified, it defaults to $00 but can be overridden at the linker script using the
fillval attribute.
What I do for vectors is make a separate 6-byte segment:
Code: Select all
; in main.s
.segment "VECTORS"
.addr nmi, menuMain, 0
Code: Select all
#in linker script
SEGMENTS {
CODE: load = ROM, type = ro, align = $100;
RODATA: load = ROM, type = ro, align = $100;
VECTORS: load = ROM, type = ro, start = $FFFA;
}
EDIT: links to relevant manual sections and example of vectors
Posted: Wed Mar 28, 2007 8:13 pm
by beneficii
tepples,
So if say, I wanted to skip ahead to $FFFA I could use that? Now, I might have made some modifications so that the body of code/data doesn't end at $F656 but at a different area; now I would not want to have to count that myself. So is it possible that I could use something like this?
.res $FFFA - *, $FF
* is the current program counter, which of course would differ depending on exactly where the code ends, right?
EDIT: Just saw your edit, reading.... ^_^
Posted: Wed Mar 28, 2007 8:16 pm
by tepples
beneficii wrote:So if say, I wanted to skip ahead to $FFFA I could use that? Now, I might have made some modifications so that the body of code/data doesn't end at $F656 but at a different area; now I would not want to have to count that myself. So is it possible that I could use something like this?
.res $FFFA - *, $FF
I'm not so sure the linker would like that method in relocatable code. Use a separate segment for vectors. For example, see the linker script in
Tetramino.
Posted: Wed Mar 28, 2007 9:18 pm
by beneficii
I'm sorry. Which of the files in Tetramino is the linker?
Posted: Wed Mar 28, 2007 10:06 pm
by tepples
From Tetramino's makefile:
Code: Select all
LD = $(CC65)/ld65.exe
# (snip)
map.txt t.prg: $(NTSCOBJS)
$(LD) $^ -C nes.ini -m map.txt -o t.prg
From
ld65 Users Guide: Usage:
So the linker is "ld65.exe" and the linker script is "nes.ini".
Posted: Wed Mar 28, 2007 10:48 pm
by beneficii
tepples,
OK.
Hmm, this is quite a bit different than any assembler I've seen before. What about combining files? Say, I have an INES header and a CHR file that I want to get combined with the BIN file to make the NES file, mm, what would be the best way to go about that? Should I include the INES header and CHR file in the main source somehow, or is there a way I can do it from the linker, or erm if it's in the makefile, I wonder what I do with it.
Posted: Wed Mar 28, 2007 11:12 pm
by tepples
beneficii wrote:Hmm, this is quite a bit different than any assembler I've seen before.
It's more than likely that you've never worked with assembly language for PC, Game Boy Advance, Nintendo DS, or anything else that uses a GNU toolchain.
What about combining files? Say, I have an INES header and a CHR file that I want to get combined with the BIN file to make the NES file, mm, what would be the best way to go about that?
MS-DOS and Windows: copy /b inesheader.bin + prg.bin + chr.bin mygame.nes
UNIX (and Windows with MSYS or Cygwin): cat inesheader.bin prg.bin chr.bin > mygame.nes
Posted: Wed Mar 28, 2007 11:28 pm
by blargg
Or just define a CHR segment and use .incbin:
Code: Select all
MEMORY {
...
CHR: start = 0, size = $2000, type = ro, fill = yes;
}
SEGMENTS {
...
CHR: load = CHR, type = ro;
}
.segment "CHR"
.incbin "chr.bin"
Posted: Thu Mar 29, 2007 5:56 pm
by Memblers
Also, in your linker config (the MEMORY part), the assembled memory banks are appended to the output file in the order you put them in. So just put the iNES header first, and the CHR last.
I just do the copy /b thing myself for the header though (and pretty much swore off using CHR-ROM). I use plain PRG ROM anyways for cart testing.