Backport https://github.com/OpenEmu/Gambatte-Core/commit/9fbc420dfbd60d7cd6f725bb223fe70b014a73a2