Fix stencil testing in the softgpu, and also some small things along the way

With these changes, stencil is preserved and written properly in the softgpu, at least per what tests I've done so far.  Star Ocean now works and stencils correctly.

All my tests were done in throughmode since I'm not very good at 3d.

I guess this fixes #3768.  The information there is still useful, though.

-[Unknown]