This approach solves the described problem very whell, but what to do when the banks are interdependent?
You'll have to compile and link them separately, but make sure to include all object files in all builds. Even though you are generating 1 bank at a time, the linker needs to know the contents of every bank to do it.
In your example above, you'll have two linker configs:
Code: Select all
# pseudo code for bank1.cfg
MEMORY {
...
CODE: start=$8000, size=$xxxx, fill=yes, file=%O; # make this just big enough to fit the library/common code
BANK1CODE: start=$xxxx, size=$xxxx, fill=yes, file=%O; # give the rest to bank1code
BANK2CODE: start=$xxxx, size=$xxxx, fill=yes; # bank2 should be identical to BANK1CODE
...
}
SEGMENTS {
... # put segment definitions here
}
Code: Select all
# pseudo code for bank2.cfg
MEMORY {
...
CODE: start=$8000, size=$xxxx, fill=yes, file=%O; # make this just big enough to fit the library/common code
BANK1CODE: start=$xxxx, size=$xxxx, fill=yes; # don't output bank1 this time
BANK2CODE: start=$xxxx, size=$xxxx, file=yes, file=%O; # output bank2 instead
...
}
SEGMENTS {
... # put segment definitions here
}
Run the linker with each of these configs, passing the object files for all banks each time. It will assign memory locations to all of the banks You'll get separate files, say "bank1.bin" and "bank2.bin". Each one will be 32kb, containing first the library code as a virtual fixed bank, then the code for the bank. That way incsp1, pusha, etc. will all be in the virtual fixed bank. Run
Code: Select all
$ cat header.bin bank1.bin bank2.bin > game.nes
to get the result.