worked on the c version of the emulator