Refactor to get a cleaner split between frames.

 - Do all end-of-frame operations at the next instruction boundary.

 - Get rid of the pending_* flags for state transfers. They are no
   longer needed since we know we're at an instruction boundary.

 - Draw the frame immediately after the visible part is finished (at the
   beginning of scanline 240). Drawing it at the very end of the frame
   no longer works since a few pixels of the new frame might get drawn
   before we reach the next instruction boundary.

   This could also reduce input lag slightly if controllers are polled
   during VBlank.

 - Calculate the logical D-pad state after left+right/up+down
   elimination in the emulation thread. This will make it easy
   to save for rewind.