Adam F. Goldberg's boyhood memories are now making their own memories.

For five seasons on ABC, the Jenkintown-raised creator of The Goldbergs has been telling stories about his life in and around "1980-something" Philadelphia, naming characters for his friends and family, and punctuating each episode with clips from the home movies that inspired them.

On Wednesday, though, The Goldbergs presents a Phillies-themed episode that's set in the '80s, but that came about only because the young Adam — played on the show by Sean Giambrone — grew up to make a hit TV show.

Called "The Opportunity of a Lifetime," it has Adam winning a radio contest for the chance to throw out the first pitch at a Phillies game, an opportunity he's happy to hand off to his more athletically inclined brother Barry (Troy Gentile).

That's the same opportunity the real Barry Goldberg, a radiologist, was offered by his TV writer brother last fall, when Philadelphia marked "Goldbergs Day." Part promotion for PHL17's launch of the show's syndicated reruns and part Goldberg family reunion, it included a stop at City Hall for a Liberty Bell presentation by Mayor Kenney; a visit to William Penn Charter School, where Adam, a 1994 graduate, spoke to students; and wrapped up with a Phillies game, where both the real Barry and his on-screen representative, Gentile, got the opportunity to pitch to Phillies legend Mike Schmidt.

Read more: Mike Schmidt adds the magic to 'Goldbergs Day' in Philly

I got some opportunities out of this myself: to ride along with the real Goldbergs and their friends that day, and in January to be on the show's Culver City, Calif., set at Sony Pictures Studios to see Gentile and Giambrone shooting a scene for Wednesday's episode with cast members Wendi McLendon-Covey, Jeff Garlin, and George Segal.

(Segal, who portrays Adam's grandfather, has his own Philadelphia and Quaker school ties. A 1951 graduate of  George School in Newtown who also spent two years at Haverford College, he told me that in those days, "I was around Philadelphia a lot," and recalled the cinnamon buns sold at the old Horn & Hardart. "You can't get that anywhere," he said, sounding sad.)

The whole experience didn't really start out as an episode, Goldberg said in a recent phone interview.

"They came up with the idea that one of the [real] Goldbergs would throw out the first pitch. They initially asked me, and that's literally my worst nightmare. So there was no world in which I would stand in front of a giant crowd and throw a ball. I immediately went to my brother, who said, absolutely — that's his dream. And his first response was [when] I asked him, 'Do you think you'll actually throw well?' and he said, 'If anything, my throw is so powerful that I'll throw over the pitcher, into the stands.' Which I thought was the perfect Barry response," he said.

Troy Gentile (left) and Adam F. Goldberg at an assembly at William Penn Charter School in September 2017. And, yes, that’s Goldberg’s mother — the real Beverly — seated proudly in the front row at right.
Ellen Gray/Staff
Troy Gentile (left) and Adam F. Goldberg at an assembly at William Penn Charter School in September 2017. And, yes, that’s Goldberg’s mother — the real Beverly — seated proudly in the front row at right.

What made it an episode was what came next. "I proceeded to watch him completely crumble over the next month," Goldberg said.

"He would send me videos of him practicing pitching like a major-league pitcher. He would be excited on one phone call; the next phone call he would be in a panic that he was going to humiliate himself. And as the days went by, he grew more and more anxious, and regretting the decision, because he thought he would choke. It really culminated [before the big moment] when he completely melted down. He forgot a baseball at home" that he'd wanted to use to practice, "and he went into his hotel room and took like a hand towel, and ran it under the sink and fashioned it into a baseball, and was throwing it at the wall in his hotel room. He completely lost it."

For his brother, "this was one of the biggest moments of his life. And our dad wasn't there to see it, and he knew for our dad it would have been the biggest thing as well," said Goldberg, whose father, Murray, died in 2008.

"My dad loved the Phillies. So when I saw my brother throwing a wet towel at the wall, I said, 'This has to be an episode.' Now, granted, this didn't happen in the '80s. It's happening before my very eyes. But it is an episode of The Goldbergs, whether it's happening to a fortysomething-year-old man or Barry as a teenager. There really is no difference," he said.

"The fact that Barry said yes, and had such confidence, which crumbled into panic and chaos — I mean, that's like the perfect episode. And then imagining what would my dad say if he was around, what would my dad put into this? It's so fun because my dad isn't here, but he still is because I get to write dialogue for my dad, and then give it to Jeff Garlin, who is my dad, and watch Jeff Garlin perform it, so it's like my dad is still with us," Goldberg said.

"It's so special, this episode, to our family," he said. "And, at the end, we do show video of my brother making that first pitch."

Viewers will also get to see Gentile's Phillies pitch.

Troy Gentile, who plays Barry Goldberg on ABC’s “The Goldbergs,” strikes a pose in the May 2 episode, in which he gets the opportunity to throw out the first pitch at a Phillies game.
Ron Tom/ABC
Troy Gentile, who plays Barry Goldberg on ABC’s “The Goldbergs,” strikes a pose in the May 2 episode, in which he gets the opportunity to throw out the first pitch at a Phillies game.

"Troy pitching is in the body of the show as if they're watching it on TV, and then we show Barry going out and pitching to Mike Schmidt, which was just like a dream on top of a dream," Goldberg said.

Schmidt showing up to catch those two pitches was "a surprise to all of us," said Goldberg, though he knew the Hall of Famer's wife, Donna, watched the show.

"We did an episode where Beverly [McLendon-Covey] bedazzles a Mike Schmidt jersey, and she reached out to our show and said, 'I want to have this jersey.'… So we made one for Mike Schmidt's wife, and I think by proxy he started watching," he said, adding that, as "one of Barry's heroes," Schmidt is mentioned quite often.

One thing you won't see in Wednesday's show is the real Barry's reaction. Goldberg quoted his brother as saying as he came off the field, " 'Can you believe I pitched to Mike Schmidt? It's a dream come true. But I didn't pitch as hard as I could have because I didn't want to hurt him, because he's older now.' So that is a classic Barry line."

Being able to write about the real people in his life has made Goldberg's writing life both easier and harder.

"What else could I want? It's a show where I get to write about my family and use my old videos," he said.  But his reluctance to hurt people sometimes frustrates his writing staff.

"Comedy writers want to write the funniest thing possible, and what happens is jokes get put into script that sell out the characters. Like there's this idea that Barry is a big dummy — he's  not a dummy, he's a doctor. And he's very smart, but, you know, he's Barry. So the writers will sometimes write lines, and sometimes lines even get into the show" that don't really represent him, Goldberg said.

"So I'm constantly trying to protect the characters. … [The writers] want the funniest script possible, but I also have to field angry phone calls from my family members," he said, adding that that extends to friends, teachers ,and others named in the show. (A '90s-set spin-off, set in the Penn Charter-like William Penn Academy, has been ordered by ABC for next season.)

"They watch the show with their families, and I don't want to hurt anyone's feelings, and I want it to seem real to them," he said. "People have trusted me with their life, to put it on to a television show. So I have to protect everybody."

What he learned on last fall's Goldbergs Day was how many Philadelphians thought of The Goldbergs as family, too.

"That was such a wild, out-of-body experience for me. Because I did not realize that this show meant something to Philadelphia. I'm in this bubble in Los Angeles, where I sit on the Sony lot in my office, writing 24 scripts a year. And then I edit them. So it's a year-round job with no break," he said.

"I do look at Facebook comments or Twitter comments, but I didn't realize that I would go into a restaurant [in Philadelphia] with my family and random strangers would walk up and say, 'Are you the Goldbergs?' Like people knew us there. It was very bizarre. And such an amazing feeling," he said.

"I was kind of just writing for my family and my friends, but it ended up kind of like speaking to the whole city. And it was something that took everyone here by surprise. We had no idea."

Watch this

8 p.m. Wednesday, ABC.