You are losing and with that state of mind you might be attempted to keep losing, but I don't think you want this to continue, do you?
The first thing is to start winning. Realize that winners keep winning and you are going to be one. Create small goals! Inside and outside work. Move! Do 5 push ups, 10, 15! Doodle simple toons, sing some music! Write a simple game on a simple framework! Sleep on time! Wake up early!
Focus on things you can control. The corporate environment, you cannot control, at least for now. Treat them like a child demanding things to their skewed worldview.
On your firing, you're looking at the worst case. There's a chance to improve, there's also a chance to explore new fields.
If you intend to keep the job, tell to your manager that you are dealing with your problems and your're getting more and more succesful. Fake it till you make it, but stay on the course so you can make good with the job.