Backport https://github.com/flyinghead/reicast-emulator/commit/99af84d7fb119f33c4f0e8f8d8db4baefaf52760