emulator code