Why mess around with code that has nothing to do with screen output?
You are just converting it to sdl.