Rewritten the emu code to use tables.
Added a generator to build tables.