Greetings Gotbail glad you are ok and you handled the situation as you did.
It is good to also know that you are interested in learning things to help prevent this from occuring again.
I have been there and it can be very challenging to get a hold of yourself and regain control.
C02 is a crazy catalyst that really kicks me in the head as well. It is no secret as others have mentioned how it makes narcosis far worse.
I have found that one needs to take your time, STOP, THINK, THEN ACT!
When planning your dive, gearing up, especially on the boat, buddy check, bubble check, and most importantly on the descent! If something feels wrong then STOP and figure it out or turn the dive.
It sounds hooky but it will slow you down and give you time to make good decisions before or after you are underwater and alter your dive plan accordingly. Ultimately if issues cannot be resolved the dive should be aborted.
I like the advice that has become a mantra for my diving, " SLOW IS SMOOTH AND SMOOTH IS FAST!" I have found this simple mantra to have helped trim many issues that were arising on my dives.
Advanced dive planning has improved the execution and enjoyment of my diving.
Always beware the rushed feeling it can lead to issues that will complicate your dives.
CamG Keep diving....Keep training....Keep learning!