Before his death by suicide in 2014, Robin Williams had a well-documented history of alcohol and cocaine dependence — a habit he kicked in 1982 after friend John Belushi’s overdose.
That’s just one of the revelations to come out of the new documentary Robin Williams: Come Inside My Mind, which airs on HBO on Tuesday night.
Directed by Marina Zenovich, the 2-hour, emotional film offers an intimate look at the the highs and lows of the star’s legendary career using never-before-seen footage of the comedian in addition to intimate conservations with his closest friends and family like Billy Crystal, Eric Idle, Whoopi Goldberg, David Letterman, Steve Martin, and Williams’ son, Zak.
All talked about the impact Williams had on their lives, but it was Belushi who appeared to have the biggest affect on Williams himself.
The two were close friends during the wild days of late-1970s, partying at comedy clubs and Hollywood bashes galore. Both had a sea of momentum behind them. Belushi was riding the success of Animal House and Saturday Night Live, while Williams had finally emerged from the standup scene to score a breakout role on the Happy Days spinoff Mork & Mindy.
Cocaine was a constant for Williams. “Cocaine for me was a place to hide,” he told PEOPLE in 1988. “Most people get hyper on coke. It slowed me down.”
All that changed in March 5, 1982, when Belushi was found dead at the Chateau Marmont in Los Angeles. A lethal combination of cocaine and heroin was found in his system.
The night before, Williams was at the Chateau Marmont, partying by Belushi’s side. According to the documentary, he would later tell Pam Dawber, his Mork & Mindy costar, that he had left the party because “he was so stoned he could hardly stand up.”
Williams wouldn’t learn about Belushi’s death until he was back on set at Mork & Mindy. Dawber had to break the news to him.
Freaked out, they left the set together. “We just walked together toward our trailers and, just before he went into his trailer, I said, ‘If that ever happens to you, I will find you and kill you first,’ ” Dawber recalled telling Williams. “And he said, ‘Dawbs, that’s never gonna happen to me.’ “
Soon thereafter, Williams got clean. “Here’s this guy who’s a beast, who could do anything, and he’s gone,” Williams said, in archival audio pulled for the documentary. “That sobered the sh-t out of me.”
Mork & Mindy director Howard Storm noticed a difference. “He backed off for a while, he cleaned up,” Storm said in the film.
RELATED VIDEO: Robin William’s Daughter Zelda on Healing—and Battling Online Trolls
After the cancellation of Mork & Mindy a few months later, Williams and first wife, Valerie, moved away from the L.A. party scene to Northern California. She was pregnant with Zak at the time.
“The Belushi tragedy was frightening,” Williams told PEOPLE in 1988. “His death scared a whole group of show-business people. It caused a big exodus from drugs. And for me, there was the baby coming. I knew I couldn’t be a father and live that sort of life.”
He’d remain sober for nearly 20 years, relapsing on the set of 2005’s The Big White. He said in the documentary: “I started drinking a tiny little bottle of Jack Daniels, like the ones you get on an airplane. Then a week later I was hiding a big bottle of Jack Daniels.”
In 2006, Williams went to rehab. He was back there nearly a decade later, in July 2014 — just a month before his death. Williams died after suffering from Lewy Body Dementia, a type of brain disease that affected his thinking, memory and movement control. It’s the second-most common type of progressive dementia after Alzheimer’s disease.