Copyright applies equally to prose and source code. So a listing of the source code can be copyrighted (and registered) with no problem.
The tricky part is when you want to release your game mechanics under one license but keep your prose under a different license. I have most of my games up under an informal license that says “For educational use only – you can learn from my code but don’t copy my game text.” This isn’t really legally supportable but it’s never been a problem.
If you want to be formal about it, extract your game mechanics, create an extension, and release the extension separately.