Use lookup tables instead of huge conditionals in rom.c