“Robin Williams: Come Inside My Mind” fittingly starts out by showcasing how the comedic master’s mind ricocheted at a dizzying velocity, bouncing around from character to character.

The new documentary, which premiered at Sundance this year before being televised  Monday on HBO, attempts to solve the mystery of that mind and what drove Williams through the years.

Director Marina Zenovich, who has also made films about Roman Polanski and Richard Pryor, interviews several of his high-profile friends, such as Billy Crystal, David Letterman and Whoopi Goldberg, as well as his first wife, Valerie Velardi, and one of his children, Zak Williams.

Much of the film’s two hours are narrated by audio clips from interviews with Williams.

The documentary doesn’t dwell for long on the circumstances of Williams’s 2014 death. According to an essay from his wife, Susan Schneider Williams, (who is not in the film), Williams had Lewy body disease and died by suicide “at the end of an intense, confusing, and relatively swift persecution at the hand of this disease’s symptoms and pathology.”

Instead, several people in the documentary note that the “sparkle had gone out of his eye” during the time Williams worked on his 2013 sitcom, “The Crazy Ones.” Crystal remembers seeing Williams for the last time when he revealed he had been diagnosed with Parkinson’s disease. “When he told me, I never heard Robin be afraid except for that moment,” Crystal says.

Here are five other things we learned from “Come Inside My Mind”:

Williams performs at the National Committee for Effective Congress in 1982. (Borsari/HBO)

He was a classically trained actor, and it came in handy

Williams first realized the power of comedy when his father, a man who did not easily laugh, “lost it” watching Jonathan Winters on “The Tonight Show.”

Eventually, Williams got into improvisational theater because it was the only course offered at his all-men’s college that also had women students. Williams later enrolled at the Juilliard School in New York, and dived into comedy in California after he couldn’t get serious acting work.

In his first paid comedy gig, the microphone died. So he went right into the audiencedoing crowd work and improvising bits. Thanks to his theater training, he could project his voice with no problem.

Many years later, Williams would display his acting range with dramatic roles in which he slowed down and exposed his vulnerability.

Letterman was initially wary

Williams first met David Letterman in the Los Angeles comedy scene of the 1970s, and the two would grow closer as they got older.

“When we first saw Robin on stage, we were skeptical, and we made it kind of a project to keep our eye on him,” Letterman recalls. “In my head, my first sight of him was that he could fly because of the energy. It was like observing an experiment.”

He got his big break thanks to “Star Wars” and an 8-year-old

“Happy Days” creator Garry Marshall noticed his 8-year-old son Scott was no longer watching his TV show. “There’s no spaceman on it,” Scott Marshall recalls in the film.

So papa Marshall asked the writers to work in a space-man character. Scott’s aunt, Ronnie, was in charge of casting and suggested a comedic street performer for the role. And boom: Williams came to “Happy Days” as Mork, an episode that earned a standing ovation from the studio audience.

Eventually, ABC spliced together a pilot by combining the Mork episode with another failed TV show, and “Mork & Mindy” was born.

He’s the reason behind the four-camera sitcom

Before Williams starred in “Mork & Mindy,” multicamera sitcoms relied on three cameras. But then came this kinetic actor who was running around the set and improvising, and the camera operators would fail to capture the antics that came when he wasn’t hitting his predetermined marks.

So Garry Marshall came up with a solution: Add a fourth, almost handheld camera to follow Williams. Since then, four cameras have been the standard for sitcoms.

John Belushi’s death had a huge impact on him

Williams was one of three people with the famously hard-partying Belushi the night he died after an overdose of cocaine and heroin.

According to the documentary, Williams learned the following day on the set of “Mork & Mindy” that Belushi had died.

His sudden death led to Williams, who had been drinking heavily and doing drugs, getting sober.

“Here’s this guy who was a beast, who could do anything, and he’s gone,” Williams said.

He would leave hilarious voice mails for Crystal

Perhaps the most intimate aspects of the documentary are the stories from Williams’s close friends and family members. His friendship with Billy Crystal began in New York City after the fellow comedic actor got Williams’s baby to stop crying.

“Everybody wanted something from him,” Crystal says. “I had no agenda. I just liked him.” Over the years, Williams would call Crystal in character, like the time he rang up as Ronald Reagan while Crystal was watching the former president’s funeral. The film includes old voice messages from Williams performing for an audience of one: his friend.

Comedy was a refuge, and an addiction

One theme in the documentary is why comedy became so integral for how Williams functioned.

After “Mork & Mindy” was canceled, Williams returned to stand-up comedy as a refuge and a survival tactic.  Even on sets for serious movies, such as “One Hour Photo,” Williams had to crack up co-stars.

“The urge to be funny and make people laugh was so innate in him and almost like breathing for him, that if he didn’t get that out of his system, it would’ve infected his performance in a bad way,” says director Mark Romanek. “So I would just let him go as long as it was reasonable for time in the day, to just get it out of his system.”

“It’s a very powerful thing for a lot of comedians. That laugh is a drug,” adds Crystal. “That acceptance, that thrill, is really hard to replace with anything else.”

Read more:

Robin Williams found dead in his home in California. Actor, comedian was 63.

‘The hardest role of his life’: Widow describes disease that drove Robin Williams to suicide