If you can find it, chapter 6 of 1994's Tricks of the Game Programming Gurus by LaMothe, Ratcliff, Seminatore, and Tyler covers it extensively in DOS C code.