I'm quite impressed about the small amount of code required for a NES emulator. I thought they'd have to do all kinds of special casing for cartridge-specific stuff…
The more accurate the emulator is, the less special casing there's a need for: special cases/hacks are necessary when the emulator takes shortcuts and doesn't implement the hardware features the game relied on. If the hardware features are fully implemented all games ought work without hacks. Hence bsnes (as far as I know) not needing game-specific hacks but requiring a hefty config to run.
The problem with the NES is that games have all kinds of different hardware inside the cartridges. In order to achieve high compatibility you need to emulate all of these chips. It's not nearly enough to accurately emulate just the NES itself.
Not all games work. Only the most popular mappers are implemented, which covers about 85% of games.
Many cartridges came with custom hardware, you have to implement them specifically, which implies special casing for the hardware, which sometimes implies special casing for the individual game.
Indeed, I didn't think it could be so simple either. Figured "what the hey" and thought about writing one in perl, but a few already beat me to it looks like: https://metacpan.org/pod/Games::NES::Emulator