Bank switching
From PHWiki
Bank switching is a technique that allows a console to access more data from a memory (such as a ROM or a NOR flash memory on a cartridge) than it can normally "see". A memory is divided into banks, and certain commands are used to switch these banks around. So-called "mapper" circuitry on the cartridge translates an address in a small domain (e.g. 16 bits) into an address in a larger domain (e.g. 24 bits), using data that the program stores in the mapper, and then passes the larger address on to the underlying memory chips. To switch banks, the program stores different data.
Bank switching on Game Boy
Bank switching on 8-bit systems such as Game Boy, NES, and Sega Master System/Game Gear generally follows along the same lines. For example, in Game Boy cartridges' most common configuration, each bank is 16KB ($4000 bytes in hexadecimal notation). The first bank (that is, the first 16KB of the ROM) is always accessible, or "hardwired", at memory locations $0000 to $3FFF and is known as "bank 0". The second bank ("bank 1") is initially accessible at locations $4000 - $7FFF. However, this bank can be switched for others by performing a bank switching operation, eg. by writing a value to address $2000 of ROM, where the value is the number of the bank to be switched. As this is ROM (or write-protected NOR memory), the existing value of the address will not be changed, but the memory bank controller (MBC) will see that bank switching has been attempted and change the bank accordingly. So, writing the value 3 to location $2000 will allow bank 3 (that is, the fourth 16KB of the ROM) to be accessed at locations $4000 - $7FFF.
Bank switching on larger systems
More modern cartridge-based systems have a large enough address space to "see" an entire official ROM. The Super NES and Genesis can "see" up to 6MB; the GBA can "see" 32 MB. On these, bank switching is generally used with copiers (such as GBA Flash Cards) so that several independent programs can be switched into the same address space, generally by the copier's menu.
