move CD tray handling out of emu loop