Backport https://github.com/mupen64plus/mupen64plus-core/commit/02e0ca5cc45435fa0a77b47eb3009ac599e91444