Fix wrong memory access when switching video modes.