Groucho Marx has taken his seat in court, where he’ll serve as the unlikely attorney for a mysterious entity known as the “Surrealist Woman.”

“You’re late!” the judge growls.

“Please, forgive my tardiness. I was out in the courtyard hiding evidence,” Groucho tells him.

“Hiding evidence is illegal!” the judge retorts.

“Illegal, you say? How am I supposed to get my client off then?” Groucho asks.

Josh Frank, the author of the forthcoming Giraffes on Horseback Salad, an adaptation of a lost collaboration between the Marx Brothers and Salvador Dalí, has spent his life preparing for such a project. This preparation consisted primarily of watching every Marx Brothers movie until the rhythms of their jokes and the nitty-gritty of their sensibility were seared into his brain; now, the author, who also operates a one-of-a-kind urban drive-in movie theater in Austin, Texas, has completed the ultimate challenge: writing his own Marx Brothers movie.

He had a little help, of course, getting an assist from artist Manuela Pertega and contemporary surrealist comic Tim Heidecker, a Temple University graduate. Given that the Marx Brothers themselves often got help with their scripts, he was more than happy to seek out collaborators. “They didn’t even write a Marx Brothers movies by themselves,” Frank said.

A few years back, Frank learned that there was supposedly a long-lost screenplay written by Dalí featuring the Marx Brothers, whom the famous Spanish artist called “the greatest surrealist comics that ever lived.” There were photos of sketches Dalí had made in preparation for his pitch that could be found with light Googling, but for Frank, a determined “pop-culture archaeologist,” it wasn’t enough.

So he kept digging.

He wrote to the Gala-Salvador Dalí Foundation in Spain to see what they could provide, and provide they did: Dalí’s Giraffes notes, in Portuguese, translated from the original French and housed in Paris. A Craigslist posting later, Frank had a translator sending him page after page of exactly what he’d been looking for. “Amazing visual ideas, a clear story, specific characters,” Frank writes in the introduction.

Though it wasn’t enough for a full movie yet, it was “all the fuel [he] needed” to keep searching. He was rewarded, after more research into Dalí’s personal life during the composition of the screenplay (1936-1939), with an email attachment of Dalí’s full screenplay notes, complete with doodles and jokes. This was all Frank needed to go ahead and turn it all into something more.

With an assist from Black Francis of the Pixies, the legendary early alt-rock band that Frank had previously written a book about, he was directed towards Heidecker of the comedy team of Tim & Eric. Heidecker, though perhaps not in possession the exact same comic sensibilities of the Marx brothers, certainly shared something with Dalí. To Frank, he was “the present-day incarnation of surrealism.”

Frank worked with Heidecker and other comedians to flesh out the story and nail the Marx Brothers’ comedic tone. “I was really nervous about that,” Frank said. “Not so much for casual viewers. It was for the people that have been loving the Marx Brothers since before I existed that I was nervous about.”

The product is the story of a richer-than-God industrialist named Jimmy who nevertheless feels morally and intellectually stifled by the mooing hangers-on that surround him. It’s only when he meets the Surrealist Woman, a supernatural being who manifests her dreams, realities and fantasies onto the world (occasionally to dire effect), that Jimmy finds himself reinvigorated by life’s possibilities. Her loyal assistant is none other than Groucho Marx.

It’s a story full of sight gags, original songs, the titular giraffes and Marx Brothers wit, ending on a bittersweet note. “It’s this mix of tragedy and comedy, this mix of disturbing and beautiful, of hilarious and horrifying,” Frank said. That contrast is greatly assisted by Pertega’s illustrations, which clearly reference Dalí while remaining distinct from him.

For Frank, Giraffes on Horseback Salad — which will be released through the Philadelphia publishing house Quirk Books — fits in with a career full of rescuing stories that might have been otherwise lost (to say nothing of his drive-in movie theater, itself an institution getting increasingly smaller in the rearview). He attributes this passion to his fascination with his grandfather and great-grandfather, the latter who fled the Cossacks for Philadelphia at 18. Back in “the old country,” Frank said, he’d had a job roping crosses on top of churches in order to clean them. “Someone told him, ‘S—t, boy, you should be a cowboy.” He moved to the border of Texas and Mexico and opened a dried goods store.

As the years went on, his grandfather had a progressively fuzzier recollection of the stories that dazzled Frank when he was young. Though that on its own was a revelation for Frank, it also led him to think about the scale of such loss.

“Think of all the other stories that might have not been as colorful, or might not have been as easy to remember, that eventually disappear,” he said. “That was sort of I think the beginning of my passion for what I do.”

He’s written a play in the past about the Golem coming alive in Nazi Germany, and a book about a nearly unknown underground cult figure in Los Angeles named Peter Ivers who was connected to artists as diverse as David Lynch and Diana Ross. His book about the Pixies posits them as an unacknowledged influence on decades of rock music. Everywhere he looks, Frank sees people and stories whose weirdness ensured that they went unappreciated in their day, but whose influence is undeniable.

He hopes to see Giraffes on Horseback Salad made into a movie one day.

“I’ll just be sitting by the phone,” he said.

[email protected]; 215-832-0740