ROM hacking, on the other hand, is perfectly legal. Nintendo couldn't care less about hacks...unless you're selling them. For perfect legality, your rom must come from your own game cartridge.
But what if you make the ROM, and someone else sells it under your name?