Was there a tiny battery somewhere in the cartridge
Yes. The battery is about the size of a nickel.
Older RAM chips could not retain their state without a constant electrical current (that tech didn't really come around until thumb drives). So as soon as they lose power, the contents of the memory is lost.
So in order to have games save their state when the cartridge is disconnected from the NES, some games put a tiny battery on the cart and connect it to the RAM, so it'll have a constant charge.
The Final Fantasy cart:
- The coin shaped thing is the battery.
- Lower-left corner is the CHR-RAM
- Lower-right corner is the PRG-ROM
- Upper-right corner is the PRG-RAM (SRAM)
- small one next to the battery (top) is the mapper
- small one next to the battery (bottom) is the CIC (anti-piracy)