OK..
First M8, welcome the the club.
It would really help if you added some details about what year RX-8 you are talking about.
Please only start one thread at a time on the same subject for the correct Series RX-8.
What SERIES RX-8 Do I Own?
I am not certain "why" you had to enter any code after a Battery Disconnect, as it is not normal or necessary to do so.
Did you removed the Audio and then reinstalled it?
I honestly was not aware of a 'lock out' on the RX-8 audio system (I know of other Mazda's with lock out), in that case of a 'lock out' you have to take car, audio and owner verification details to a Mazda Dealer and get it re-coded....there is no other way that I am aware of.
Someone else may be able to confirm for US markets.