A man who declined a court-appointed attorney and is defending himself for his alleged role in the shooting death of an off-duty Chicago police officer earlier this year sparred with a Cook County judge and prosecutors at a hearing Thursday.

While discussing which evidence can be introduced at an upcoming trial, Jovan Battle, 32 — who has a history of mental illness and homelessness — balked at the prosecution’s request to share with jurors his history of drug arrests.

It was an apples and oranges matter, he argued.

“That’s bogus,” he said, pointing at prosecutors. “You’re talking about selling drugs at a murder [trial] ... keep it real.”

Cook County Judge Dennis Porter stepped in several times to explain various legal procedures to Battle.

“You’re a prejudiced judge, but I’m still respecting you,” Battle told him.

Battle is charged with murder in the March 25 fatal shooting of off-duty Chicago Police Officer John Rivera.

Battle allegedly pointed out Rivera, seated with friends in a parked car on Clark Street in River North, to co-defendants Menelik Jackson and Jaquan Washington.

Battle told the pair Rivera was part of a group of men who had fought with Jackson and Washington earlier that night in front of a nearby McDonald’s, prosecutors allege. Police say surveillance shows Battle pointing at the car with a liquor bottle, and Jackson walking up to Rivera’s car with a .40-caliber pistol and shooting Rivera as the officer turned to provide cover for his girlfriend in the passenger seat.

Battle considered himself a “good Samaritan” who was helping two other members of the same gang when he encountered Jackson and Washington and aided them in their quest for reprisal, prosecutors allege.

However, Rivera had nothing to do with the previous fight and was just out for a night on the town, an incensed Supt. Eddie Johnson said shortly after the shooting.

Last month, based on a court-ordered psychiatric evaluation, Porter found Jovan Battle mentally fit to stand trial and grudgingly granted his request to dismiss a court-appointed assistant public defender and handle his own case.

Porter also explained to Battle that he will get no more access to the law library to prepare for his case than other jail inmates who have lawyers.

He also emphasized that, if he is convicted, Battle would not be able to base an appeal on any claim that he had ineffective legal counsel.