Backport https://github.com/mupen64plus/mupen64plus-core/commit/9e229f7d72f88ef6f6146dd8d0258e1ae249d359