FinalZero wrote:ca65 delegates placement of code in the binary image to the linker.
So then, does .org do anything at all in ca65 asm?
Yeah, it screws it up, don't use it. Seriously, I tried to use ".org" to create a very specific layout for my zero-page variables, to make viewing them in FCEUX's debugger easier. However, after using ".org" and ".reloc" a few times, the assembler produced unlinkable code. I don't remember the exact error. So I replaced my usage of ".org" with lots of ".aligns" and ".assert" and I hand-tune my variable declaration list whenever an assert fails. I also use lots of "structs", but I'm a C junkie.
Ex:
Code: Select all
;; For ease of debugging, we want the "Yar" and "Quotile" at multiples of 16
.align 16
.assert (* = $30), error, "Zero-page layout"
qotile_obj: .tag OBJ
qotile_dat: .tag QOTILE
.align 16
.assert (* = $40), error, "Zero-page layout"
yar1_obj: .tag OBJ
bullet1_obj: .tag OBJ
FinalZero wrote:
Yes, just like a typical C toolchain.
Ok. It sounds stupid but I didn't realize it was so. It didn't help that other assemblers simply skip the linker step... With this in mind, my project assembles and links, and then plays in FCEUX without generating an error!, but the screen is blank and nothing happens... I don't have the linker set up correctly yet...
If you wish, post your linker config somewhere and we'll take a look at it.
I also recommend that you enable the linker map file and debug file and review them. They will show you where the linker actually put stuff.
Also just load the ROM into FCEUX and look at it in the debugger. Are the three 6502 vectors ($fffa - $ffff) set properly?
You can use FCEUX's debugger to single-step through the execution of your ROM. FCEUX can also take as input a "symbol file", but I'm yet to write a tool to convert the ld65's ".deb" file into something that pleases FCEUX. When I do, I'll happily share it (but it will be in perl). Tepples might be willing to create one in python, or convert mine. I don't know python.
FinalZero wrote:
@clueless: Thank you for the script. I don't know Perl (I know some Python, but have never written anything major in it), but I have to get around to learning it sometime...
Sure! I believe in sharing and giving back to the community and helping anyone that genuinely wants it.
I think that you are slightly mistaken. I did not create that thread, I have no posts in it, and its only one page long.
I read that thread when it came out. I never noticed the bug in ca65. Since my code works fine, I've not bothered to patch. This is what I use:
Code: Select all
djenkins@hera ~/code/nesyar $ ca65 --version
ca65 V2.13.2 - (C) Copyright 1998-2005 Ullrich von Bassewitz
FinalZero wrote:
Thank you to all for answering all my questions so far, especially when the average internet board would eat somebody alive for something like this.
Certainly. You are most welcome. We feed rude noobs to NovaYoshi. We keep the good ones.
One more suggestion: Read the ca65 and ld65 docs a few times. Just pick some small section and read about a feature. You might not use it right away, but you'll learn what is available for when you might need it.
You won't need all features either, so if something looks really bizarre, skip it.
If you need to, write your own run-time "assert" logic. When an assertion fails, execute the invalid instruction $02. This will "halt" the CPU. Then set a breakpoint inside FCEUX to trip on invalid opcodes (there is a checkbox for this).
Ex:
Code: Select all
lda player_energy
cmp #MAX_ENERGY
bcc ok
.byte $02 ;; 6502 "KILL" opcode.
ok: