Below is a diagram showing the order functions/procedures are called, and where they're called from.
Note that it does not consider that a section of these will repeat as part of the game looping.