Skip to content
Bananattack edited this page Aug 18, 2011 · 2 revisions

The Language Reference - Bank Definitions

Bank definitions used to create named memory areas for laying out a program in nel. They define sections that reserve space for variables, code, and data that will end up in the final program. To define a bank, simply write bank name : type[size] where name is what to call this program bank, type is the kind of bank to define, and size is the number of bytes this bank will occupy. The type can be ram (for defining variables; no actual space in the final ROM), prg (for program code and data in PRG ROM), or chr (for tile and sprite graphics stored in CHR ROM).

If a program has no chr banks, it's assumed to have CHR RAM, which some cartridge mappers can use to dynamically load graphics onto the NES's PPU. The resulting .nes file that nel will output will have the total PRG space rounded to the nearest multiple of 16K (16384 bytes), and the total CHR space rounded to the nearest multiple of 8K (8192 bytes). All unused CHR and PRG areas are padded with the value 0xFF.

Depending on what cartridge mapper your program requires, you may want to size the various ROM banks in different multiples (1K, 4K, 8K, 16K, 32K), and there may be extra on-cartridge RAM for more variables and for keeping save data. Figure out what mapper you plan to use, and lay things out accordingly.

And once you have banks defined, you will probably want to actually use them. Relocation directives allow you to jump between banks, and from there, you can define variables, data, and code inside of your banks.

Example

This shows some bank definitions:

ines: mapper = 0

let K = 1024
bank ram : ram[2 * K] // System RAM.
bank prg : prg[32 * K] // 32K of program code.
bank chr : chr[8 * K] // 8K of graphics.