Rewrite raw memcard threading code. Intended to fix issue 7484.

I think this is because of github's tab size. Still shouldn't be this way, IIRC it should only be tabbed in once?