Backport https://github.com/simias/beetle-psx-libretro/commit/be8e76d3eb5640cad0d7d423ac34e008978b0869