Taken from Graphics Programming Black Book by Michael Abrash, chapter 49.
Written using Borland C++ 3.1 under FreeDOS inside 86Box
I used WinImage to get files in and out of the emulated DOS machine's hard disk image.
Install all the stuff above, clone this repo, get it into your emulated DOS machine and then type
BC L49-5
It should open the project, you can then compile and run it from the menu.