This change is based on @silbinarywolf's change: https://github.com/hajimehoshi/ebiten/issues/798#issuecomment-457822280 Fixes #798