Backport https://github.com/libretro/mednafen-psx-libretro/commit/549a3cbdcc57cbd802a380ce31ad1090bd086685