BERKELEY — Things were already going poorly for a local resident suspected of selling MDMA and other drugs from his apartment — the cops had been called there for a report of a woman being held hostage, and found the suspect blocking the doorway with suspected drugs in a bag on a table behind him.

But as police were searching the home — where they’d allegedly find more than 32 pounds of marijuana, 1.5 ounces of MDMA, and a half-ounce of cocaine — things got even worse for the 37-year-old Berkeley man. A text popped up from “Big Ricky” on his phone, which at this point was in police possession, according to court records.

“You still want a kilo?” it allegedly read.

Now the man has been charged with felony counts of selling controlled substances and misdemeanor charges of battery, resisting arrest, and being a marijuana dealer. He has been released from jail while the case is pending and is next due in court on May 15 for a preliminary hearing, records show.

The charges stem from a March 21 police call, where a woman claimed her friend was being held hostage by a man on the 1200 block of Ashby Avenue in Berkeley. Police responded and found the 37-year-old man — the victim’s boyfriend — blocking the doorway. Police said in court records he “refused to comply with Officer’s commands and continued to block access to the victim,” who remained inside.

Police handcuffed him, located the woman inside, and began searching the home after an officer noted a “white powdery substance” on a table inside. The suspected drugs were found, along with, “shipping material, a ledger sheet, vacuum sealable packaging material, vacuum sealers, and narcotics,” police said in court records. Then the text from “Big Ricky” came in.

The man has pleaded not guilty.