First draft of code.  Works, but does give cursor scanlines.