Clarify tick_ppu() by breaking out some functions.

Also use a switch instead of an if for checking the dot ranges for the
visible scanlines.