Had been doing that in DOS in assembler when I was a kid (combined sound playing + joystick polling routine. Though I also did some of the sound mixing...