Since I was writing some GTROM documentation, and wanting to include templates for a few different assemblers, I decided to include a simple utility for duplicating data among 32kB banks, rather than complicate the source code for the templates. I'll be using it myself with CA65. I don't know if anyone else wants it, but here it anyways. C source is included.
edit - bugfix v1.1 added 11-16-2018
edit - bugfix v1.1 added 11-16-2018
Code:
Fixed Bank Creator
by Memblers
V1.0 - 11-14-2018 - initial release
v1.1 - 11-16-2018 - bugfix: blank check fail warning would corrupt source
bank selector
-- Introduction --
Fixed Bank Creator is a utility designed for NES developers who are using a
mapper that bankswitches PRG-ROM in 32kB pages. It will allow you to take
code/data from one bank, and duplicate it to the same address in every bank.
You could do this with your assembler/linker, but the methods for doing so
vary by assembler and can become convoluted, with issues such as having
conflicting label names within the same scope. Because this program operates
on a binary file, it doesn't matter which assembler you are using.
Whether you've already developed with 32kB banks and are tired of dicking
around with an overly-complicated build process, or you are a UNROM veteran
looking to shrink your fixed bank and free up more memory on boards such as
GTROM, it is hoped that this program could be useful to you.
-- Usage --
Fixed Bank Creator is a command-line program, intended to be run as part of
your normal ROM-building process. You specify the input ROM file in .NES
format, address range for the desired fixed bank, and (optionally) an output
filename. You do not need to specify a source bank, as the program will
detect which bank already has data within that range. If data exists within
that range in multiple banks, a warning message will be output.
fixbank.exe [.NES file] [begin address] [end address] [optional filename]
Usage examples:
fixbank hotseat2.nes $C000 $FFFF
Creates a UNROM-style 16kB fixed bank, saved as "output.nes"
fixbank hatetank.nes FFFA FFFF romtest.nes
Duplicates the vectors only, saved as "romtest.nes"
fixbank romtest.nes 0xE000 0xE7FF
Duplicates 2kB data, DPCM samples for example, saved as "output.nes"
When creating your ROM to use the program, what you are supposed to do is
choose the region of memory (anywhere in $8000-$FFFF) that you would like to
make into the fixed bank. Organizing your program into 32kB banks, you then
leave that region empty (padded with $00 or $FF bytes) in every bank, except
for one of them. The contents of that one bank will then be duplicated.
-- Notes and Tips --
Warning, Error, and Info messages are output to the screen. The warning
messages should not be ignored, as they are likely indicators of a
non-working result.
'$F000', 'F000', and '0xF000' are all valid input syntax for this program.
After the source bank has been detected, the rest of the banks are scanned to
check if they are blank. If they are not, a warning is output and data will
be overwritten.
Blank check requires memory to be padded with either $00 or $FF. If you use
$FF, FlashROM and EPROM chips may be slightly faster to program, as $FF is
the typical blank state of non-volatile memory.
Searching for source data bank begins in the lowest bank. It's recommended
that you put your fixed bank source data in the lowest (first) bank.
It's best if you set up your assembler to reserve memory in your fixed bank
area, as the error messages from your assembler will likely be more helpful
than the warning messages from this program.
If you need to create multiple "mirrored" parts of memory, just run the
program again on the output file.
This program is free and open source under the MIT license. Additionally,
any discordian pope may automatically grant themselves a license under the
WTFPL, as desired.
-- Known Issues --
The source bank detection will fail if you were to create a bank that
consists entirely of $00 and/or $FF bytes. If, for some reason, you wanted
to have nothing but patterns of $00 and $FF bytes in your fixed bank, this is
bad news.
by Memblers
V1.0 - 11-14-2018 - initial release
v1.1 - 11-16-2018 - bugfix: blank check fail warning would corrupt source
bank selector
-- Introduction --
Fixed Bank Creator is a utility designed for NES developers who are using a
mapper that bankswitches PRG-ROM in 32kB pages. It will allow you to take
code/data from one bank, and duplicate it to the same address in every bank.
You could do this with your assembler/linker, but the methods for doing so
vary by assembler and can become convoluted, with issues such as having
conflicting label names within the same scope. Because this program operates
on a binary file, it doesn't matter which assembler you are using.
Whether you've already developed with 32kB banks and are tired of dicking
around with an overly-complicated build process, or you are a UNROM veteran
looking to shrink your fixed bank and free up more memory on boards such as
GTROM, it is hoped that this program could be useful to you.
-- Usage --
Fixed Bank Creator is a command-line program, intended to be run as part of
your normal ROM-building process. You specify the input ROM file in .NES
format, address range for the desired fixed bank, and (optionally) an output
filename. You do not need to specify a source bank, as the program will
detect which bank already has data within that range. If data exists within
that range in multiple banks, a warning message will be output.
fixbank.exe [.NES file] [begin address] [end address] [optional filename]
Usage examples:
fixbank hotseat2.nes $C000 $FFFF
Creates a UNROM-style 16kB fixed bank, saved as "output.nes"
fixbank hatetank.nes FFFA FFFF romtest.nes
Duplicates the vectors only, saved as "romtest.nes"
fixbank romtest.nes 0xE000 0xE7FF
Duplicates 2kB data, DPCM samples for example, saved as "output.nes"
When creating your ROM to use the program, what you are supposed to do is
choose the region of memory (anywhere in $8000-$FFFF) that you would like to
make into the fixed bank. Organizing your program into 32kB banks, you then
leave that region empty (padded with $00 or $FF bytes) in every bank, except
for one of them. The contents of that one bank will then be duplicated.
-- Notes and Tips --
Warning, Error, and Info messages are output to the screen. The warning
messages should not be ignored, as they are likely indicators of a
non-working result.
'$F000', 'F000', and '0xF000' are all valid input syntax for this program.
After the source bank has been detected, the rest of the banks are scanned to
check if they are blank. If they are not, a warning is output and data will
be overwritten.
Blank check requires memory to be padded with either $00 or $FF. If you use
$FF, FlashROM and EPROM chips may be slightly faster to program, as $FF is
the typical blank state of non-volatile memory.
Searching for source data bank begins in the lowest bank. It's recommended
that you put your fixed bank source data in the lowest (first) bank.
It's best if you set up your assembler to reserve memory in your fixed bank
area, as the error messages from your assembler will likely be more helpful
than the warning messages from this program.
If you need to create multiple "mirrored" parts of memory, just run the
program again on the output file.
This program is free and open source under the MIT license. Additionally,
any discordian pope may automatically grant themselves a license under the
WTFPL, as desired.
-- Known Issues --
The source bank detection will fail if you were to create a bank that
consists entirely of $00 and/or $FF bytes. If, for some reason, you wanted
to have nothing but patterns of $00 and $FF bytes in your fixed bank, this is
bad news.