We do have a formal one. In practice that is not so clear, as the many corruption cases show, with political use of the police included.
Also they not only have declared the referendum illegal, but are persecuting everyone promoting the referendum, so much for freedom of speech. But anyways, now you get into a criminal trial for making jokes about terrorist actions from 40 years ago against Franco ministers.
I am Andalusian and I'd be happy to keep Catalonian withing the Spanish state, under a federalist republic where we can move forward together. But in the current state of affairs I very much understand the independentist movement. Having a referendum is the only solution long-term and the Spanish goverment just uses legalist excuses to stop it. What they don't say is that precisely they can change the law to allow it!