Backport https://github.com/libretro/beetle-psx-libretro/commit/488152765da64a0edc60e59b746baf01415ac081