Bill Cosby arrived in court Wednesday for Day 2 of his bid to get the sexual assault case against him thrown out over an unwritten promise of immunity that a previous district attorney says he gave Cosby’s now-dead lawyer a decade ago.

Supporters yelled "We love you, Bill!" as the 78-year-old comedian made his way slowly into the courthouse with assistants to either side of him. Cosby uses a cane, and his eyesight is said to be deteriorating.

Cosby, 78, was arrested and charged in December with drugging and violating former Temple University athletic department employee Andrea Constand at his suburban Philadelphia mansion in 2004. He could get up to 10 years in prison if convicted.

On Tuesday, Judge Steven T. O’Neill puzzled over the testimony of former District Attorney Bruce Castor and peppered him with questions as Castor wrapped up hours of testimony as the star witness for the defense at the pre-trial hearing.

Castor testified that he believed Constand’s story but found serious flaws in the case in 2005 and declined to bring charges. He said that as district attorney, he considered the decision final and binding "for all time" on his successors.

Castor suggested that Cosby and his then-lawyer, Walter Phillips, had the same understanding because the comic later agreed to testify without invoking his Fifth Amendment right against self-incrimination in a lawsuit brought against him by Constand.

"Cosby would’ve had to have been nuts to say those things if there was any chance he could’ve been prosecuted," Castor said, referring to the damaging testimony from a deposition unsealed last summer.

Phillips died last year.

Castor said that in ruling out any prosecution of Cosby, he hoped to prod the TV star to testify in the lawsuit. "I was hopeful that I had made Ms. Constand a millionaire," he said. Constand eventually settled for an undisclosed sum.

"If there was an agreement, why didn’t you make that agreement in writing?" the judge asked Castor.

"It was unnecessary because I concluded there was no way the case would get any better," he said. He also said Cosby was afraid such an agreement would make him look bad.

Kevin Steele, the newly elected district attorney who is pursuing the case, has said Cosby would need an immunity agreement in writing to get the case thrown out.

The judge said he hoped to rule Wednesday on the request to dismiss the charges.

Dozens of women have accused Cosby of drugging and sexually assaulting them since the 1960s, destroying his good-guy image as America’s Dad. But the statute of limitations for prosecuting him has run out in nearly every instance. This is the only case in which he has been charged.

It was the unsealing of the testimony from Constand’s lawsuit that prompted Castor’s successors to reopen the case and ultimately charge Cosby.

Cosby admitted in the deposition that he obtained quaaludes to give to women he wanted to have sex with and that he gave Constand three pills at his home. He said he reached into her pants but insisted it was consensual.

Castor defended his decision not to bring charges, citing among other things Constand’s yearlong delay in reporting the allegations, her continued contact with Cosby, and suggestions that she and her mother might have tried to extort the TV star.

(Copyright (c) 2016 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed.)

Join our Newsletter for the latest news right to your inbox