It controls the spark timing in a manner very similar to the stock ECU on many fuel injected cars. In its standard distributor mode, Megasquirt starts by reading a signal from a distributor pick-up that always happens at the same number of degrees before the next cylinder to fire reaches TDC. It calculates the spark timing based on manifold pressure and engine RPM.
If this trigger occurrs 50 degrees or more before TDC, Megasquirt will start counting down a time-based delay and then trigger the ignition through either a built-in VB921 power transistor or an external module like an MSD box. If the trigger angle is 20 degrees or less, it will work in "next cylinder" mode, where Megasquirt will predict when the next pulse will arrive. The output is about the same.
See here for a very detailed description about how the timing calculations work:
http://www.msextra.com/manuals/MS_Extra_Software_Manual.htm#this_next
The distributor cap does have a fair amount of provision for timing advance and retard - the stock ignition control changes things by tens of degrees, after all.