Integrate more code from mednafen.cpp into libretro.cpp