I do believe you are correct, I have tried it a few different ways and each time I have gotten a code, was when Zorg was defeated. It did not matter how many batteries, or medals I had gotten. So I think, that no matter if you have a score of 1 and 0 medals, as long as you defeat Zorg, you will get a code. Now, how to defeat Zorg is a different story. I do not have any confirmation on this but I have tried a few ways, what seems to happen, at least to me, is that when I get the last battery (the one that is yellow with red) that is flying around just before you have to defeat Zorg, it gives you two times the firing power, each time, I have defeated him, I have yet to defeat him without it. So this may be a clue, dunno?