I'm not familiar with the NES in particular, but typically the software is synced with the video signal via hardware interrupts.