Bankswitching#

The 6507 has 13 address lines, so it can see 8 KB at most — and only the upper 4 KB ($F000$FFFF) is the cartridge window. That’s the hard ceiling: an unbanked cart is 4 KB, full stop. Every larger game gets there the same way — extra hardware on the cartridge swaps which 4 KB is visible in the window.

This page is the hardware: how the cartridge pages ROM in and out, and the named schemes that do it. Writing code that survives those swaps — the matching stubs, the reset vectors, the traps — is the next page, Programming Across Banks.

One window, many banks#

Picture a 16 KB ROM as four 4 KB banks. The console can only ever see one at a time, through its single 4 KB window. Cartridge logic decides which:

Hotspots: switching with no instruction#

Here is the part that surprises everyone: there is no “switch bank” instruction. The 6502 doesn’t know banks exist. Instead, the cartridge watches the address bus, and accessing certain addresses — “hotspots” — triggers the swap as a pure side effect. Just touching the address does it; the read or write itself is incidental. This is the whole reason the trick can work: the cartridge has nothing to go on but the addresses the CPU puts on the bus, so it makes a handful of those addresses mean “switch.”

    bit $1FF9        ; the access to $1FF9 IS the switch — bank 1 is now live
    ; ...execution continues from here, but in bank 1's copy of this code

The standard Atari schemes are named for their hotspot addresses up near the top of the window:

SchemeROMBanksHotspotsSeen in
F88 KB2$1FF8, $1FF9Asteroids (1981) — the first banked cart
F616 KB4$1FF6$1FF9Crystal Castles, Dig Dug
F432 KB8$1FF4$1FFBFatal Run — the largest official Atari cart
3Fup to 512 KBmanya write to $3F (Tigervision)Miner 2049er

(Others exist — E0, FE, 3E, and more — but F8/F6/F4 cover most Atari-era carts.)

That the swap is invisible to the instruction set is a gift and a hazard in equal measure. It means a larger ROM needs no new opcodes — but it also means an innocent-looking access can pull the rug out from under your own running code. Both consequences belong to the software side: Programming Across Banks.

In Practice#

  • Pick the scheme before you write much. Bankswitching shapes how you lay out code (what lives in which bank, where the stubs go), so choosing F8 vs. F6 isn’t a late decision — it’s architecture. The physical side is in Preparing the ROM Image.
  • The hotspots are the same addresses in every bank. Because the cartridge decodes the address no matter which bank is showing, a hotspot reaches the switch from anywhere — which is exactly what makes the matching-stub trick on the next page possible.