They were especially intrigued by how often he deftly sidestepped any responsibility for a coldblooded business that financially benefited a few at the expense of many. He even recommended a theme song for the show, which he would not live to see: “New York, New York.”

“In other words, he had a very romanticized view of his life,” Mr. Pelecanos said. “He never really felt responsible for the attrition around him.”

Their Virgil into this seamy world spoke frankly of the human toll. If the writers asked whatever happened to so-and-so, Mr. Simon said, “The answer was never ‘She married a podiatrist, moved to Scarsdale and had two kids.’”

Let us pause here.

The Times Square of today may be a Disney dystopia, a soul-crushing slice of Midtown where musty Elmo costumes go to die. But the fashionable yearning for the seamier Times Square of yore is to wish for the return of live sex shows, peep-show stalls in constant need of cleaning, men beating women on the street, rampant drug use and underage prostitution.

Yes, those were the days.

But Mr. Simon and Mr. Pelecanos recognized the storytelling potential of those days, and the opportunity to examine so much: the moral implications of economic models, the misogyny, the artistic contributions to music and sensibility, the sexual repression and liberation, the advent of AIDS, the sex-video business shifting to the West Coast, the impact of forever-accessible porn on human interaction and intimacy.

But in taking on New York and the Deuce, the co-creators recognized that among the many pitfalls to avoid was any lapse into what Mr. Simon called “the boys’ version of the sex industry.” He said that the writers, directors and actors engaged in intense, scene-by-scene discussions during the shooting of the first season’s eight episodes. Gay and trans writers contributed to the teleplays, women directed four of the episodes, and Ms. Gyllenhaal, one of the producers, shared her notes on scripts and edits of episodes.