I am currently using NESASM, and I am restructuring the code from the Nerdy Nights tutorial to
use separate files. I have taken the code from the tutorial that very simply displays a 2 x 2 sprite that
moves when you use the controller.
I have read up on the NESASM readme file and I still don't grasp the .bank directive.
The problem I am faced with, is when or where to .include my source files.
I include my NMI routine right where the tutorial had it posted and it works fine.
I guess my question is a bit more oriented about program memory as well. Like, if i .org at $E000,
does my ROM reserve $E000 - $E0FF at that bank?
Can I just .include all my files at the beginning of my main file?
PS: I am planning on converting my code to ASM6 because it has some neat features. Are there any suggestions
or things I need to keep in mind?
program banks
Moderator: Moderators
Re: program banks
.bank is just selecting from an 8K bank. .org says "This is where this location in ROM starts" basically. Banks in NESASM are 8KB.so .ORG would reserve $E000-$FFFF, not 256 bytes.
Re: program banks
An .org directive tells the assembler what values to use when labels are replaced with absolute values.
Re: program banks
In some (most?) assemblers (but not CA65, because you shouldn't be using .org in it anyways), it also adds padding up to the new location.Movax12 wrote:An .org directive tells the assembler what values to use when labels are replaced with absolute values.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
Re: program banks
From what I understand, NESASM requires the .bank directive to organize your ROMs into "blocks" of 8KB. AFAIK, it can't automatically rollover to the next bank in case you reach the end of the current one, so you really need a ton of .bank directives.johnnystarr wrote:I have read up on the NESASM readme file and I still don't grasp the .bank directive.
.org doesn't reserve anything. It's purpose is to tell the assembler where in the address space of the target machine's memory the program is supposed to be loaded, so it can calculate the correct addresses for labels. The first .org in the program just sets the initial address, but any .org after that pads the ROM up until the specified location, to ensure that the code/data that follows it does indeed fall into the desired place.I guess my question is a bit more oriented about program memory as well. Like, if i .org at $E000,
does my ROM reserve $E000 - $E0FF at that bank?
That depends on what the included files contain. If it's just subroutines and interrupt/NMI handlers and you're not using bankswitching, yeah, they can go anywhere. Things get more complicated once bankswitching comes into play, because you may have to deal with reset stubs and tampoline code (which must be at specific locations of every bank) and keep track of which banks are mapped at any given time (e.g. if you put an interrupt handler in a bank that's not mapped in when an interrupt fires your game will most likely crash).Can I just .include all my files at the beginning of my main file?
I'd say that's a good idea. If you need some reference, here are some templates I made a while back.I am planning on converting my code to ASM6 because it has some neat features.
Re: program banks
It errors when code swaps over to another bank, not sure if it assembles. But INCBIN's roll over to every consecutive bank.