A boy was forced to defecate on the floor after being locked in a room "not fit for a human", a court has heard.
The child, from Northampton, was also beaten and made to sleep next to his brother on a filthy mattress with the springs sticking out, it was said.
Northampton Crown Court heard he was not fed properly and survived on leftovers.
His parents, who cannot be named, deny multiple charges of child cruelty between 2012 and 2016.
Prosecutor Grace Hale told jurors that he was kept in a room that locked from the outside and had an alarm fitted.
Giving evidence, one of the brothers said their parents "treated us all the same" and if anyone was hurt, it was only through "play-fighting".
Asked about his relationship with his father, the youngster said: "I loved him and he loved me. We had a very strong relationship. He treated me very well."
When Ms Hale questioned why what he was saying in court was different to what he told police after they visited the family home, he replied: "I was saying stuff happened that didn't."
The trial continues.