In “Difficult Men: Behind the Scenes of a Creative Revolution: From ‘The Sopranos’ and ‘The Wire’ to ‘Mad Men’ and ‘Breaking Bad’ ”, author Brett Martin charts the transformation of television in the late 1990s and early 2000s from a medium that kept things safe to one that explored complex characters in dark fictional worlds with few happy endings.

Because most of the cable TV writers he discusses were men, the characters most prominent in series like “The Sopranos” and “Breaking Bad” tended to be “difficult men” -- but these shows also featured some of the most complex female characters ever written for television.

International Business Times talked to Martin about his book and his reaction to the news that one of network TV’s iconic “good guys,” Bill Cosby, has been recast amid an ever-increasing number of rape allegations as a “difficult man” himself.

IBTimes: You attribute the shift of show themes toward the dark side in part to cable writers not having to appease advertisers, as well as to the age of the mostly male writers. Do you think there was also a cultural need to see antiheroes? Or at least, more complex, damaged people?

Martin: These stories were suppressed actively by advertisers and there was the shared belief that you can’t tell these stories on TV. There was a notion that people didn’t want them in their homes, that TV is there to make you feel comfortable. But HBO didn’t have ads, and brand and buzz were as important as eyeballs. There was an emerging gap in adult storytelling.

We were at a moment of unease, heading into the 21st century. It was a profound era of unease about traditional male power and how we were using it in the world, how it was being used and misused. That was part of the political and cultural landscape. Also, a generation of writers lived through the dislocations of what it is to be a man.

IBTimes: In your interview with “Six Feet Under” creator Alan Ball, he says something about how we eroticize power. “They’re still in love with Big Daddy, even though they hate him.” Can you say more about this?

Martin: Tony Soprano was an undeniably sexy figure. I knew women and men who were conflicted about finding him compelling. We have a queasy relationship with these men that becomes part of the seduction and engagement. That’s why you’d hear a lot of people asking, “Are you still rooting for Walter White or Tony Soprano?” Not “I love him” or “I hate him.” It’s a queasy relationship, but it certainly creates an active viewing experience.

IBTimes: Why does “serious” TV have to mean pathological? Sociopathic? Violent?

Martin: It’s less true now than it was in the period I wrote about, which was marked by that. Part of the reason is, it was an imitation of what was working. Also, that first wave, the leading edge of men who were writing were staking claim to a new kind of auteurship and exploring those issues of masculinity I talked about earlier. And that kind of story was uniquely suited to an America that was turning to these kind of stories.

That “Mad Men” era is drawing to a close,and there are different stories and voices out there. Also, so much of what those shows had to do was convince an audience that there could be quality TV, but they don’t need to be so reliant on genre now.

IBTimes: You mention the series “Girls” briefly in your book. That show was supposed to present a more realistic New York than “Sex and the City,” which itself was a show with complex female characters. Is the trend of presenting “warts and all” characters going to continue on TV?

Martin: Generally, the move is toward realism -- complicated characters, well-written characters, like people we see walking around. In great literature, characters have many facets. HBO’s brand, for example, is “rawness.”

IBTimes: Are we going to see “difficult women”?

Martin: We’ve been seeing difficult women. They were there in "The Sopranos," more explicitly in "Damages," Carrie from “Homeland.” We’ve seen some of the best-written, most complicated, humane, fascinating female characters. It’s really been a golden age of character.

IBTimes: Given this trend toward “dark” on TV, it seems a little out of touch that NBC was thinking of giving Bill Cosby a new show. He seems like the very sort of “affable patriarch” who is anachronistic. And given the recent rape allegations against him ...

Martin: I think it’s another sign of how networks are continuing to -- I’m being kind here -- pursue another strategy. They’re still bound to get a wide audience. The key to these other shows is that they didn’t have to go by that. The audience that watched “Breaking Bad” is still small by network standards. So they’re still playing by the old rules.

Regarding Cosby, it’s a neat irony that the ultimate TV good guy turns out to be like a character off of cable.