First shot at rewriting this...
Closer...
I fix ^.`

Clamp X to 160, not 159, so the last pixel is written.
Tile index is * 32, not * 16 (you need another power of 2).
You have to shift from the other way.
I fixed X scrolling!
Hilariously break OAM a little less.
Pass-through writes outside v/hblank

Fixes (SOME) sprite glitching in Gold
Remove redundant .params from lcdc state structs
Optimise more
Optimise a bit
Fix SDL2 on Windows

Need to test it on Unix before merging to master
More fixes

#include <SDL.h> because it is needed
Shut up warnings on Unix

Hilariously, even at /W4 MSVC doesn't care about these redefinitions
because they are redefined to the same value so it doesn't matter.
Merge remote-tracking branch 'origin/sdl2-windows'

Conflicts:
	src/frontends/sdl2/audio.c
	src/frontends/sdl2/event.c
	src/frontends/sdl2/input.c
	src/frontends/sdl2/video.c