what theme is that when you battle eggman
This was one of my favorites when I was little!
Some tips for fighting Eggman:
Heal everytime your health falls beneath 2000 HP. Most of his attack do just over 1000, but its best not to risk it.
If he is charging the Master Emerald, and your health is beneath 2500, you wont make it unless you heal.
As tempting as it might be, dont use the G. Beam against him. Using a Triple Shot 2 times does pretty much the same damage for not even half the EP cost. I also dont recommend doing any Magic Attacks except Heal and Protect, as they prove to be innefective.
When he isnt charging the Master Emerald, use regular attacks. When he is charging the Master Emerald, use the Triple Shot.
Repeat all of these tips and Eggman will eventually have enough.