TTS calculation

Does anyone know how TTS is calculated?

I cant find any formulas for how this is derived.  I get that it is an amalgam of the NDL as well as stops for NDL and similarly for decompression diving but i still would like to know how its derived.

Thanks