not to be discouraging, but good luck, the P0300 is a hard one to track down many times. just having spark doesn't necissarily rule out that its spark related though. how have you been with the maintenance? how does the cap/rotor look at the contact points? with the cap off, how much play do you feel in the distributor shaft? any other codes along with it? when did you last do a FULL tune up?
first thing is first, if you haven't done a good tune up in a little while, you need to, new plugs/wires/cap/rotor/fuel filter/oil filter/oil change/air filter/PCV and check the alternator and battery, check the coolant level and fluid health, check all other fluids, check fuses and cable connections/grounds, inspect old spark plugs...probably a few other things I left out.
if after you do all that, its still having a rough idle and P0300, you need to check your fuel pressure with both key on engine off and watching the pressure fall rate afterwards, and while running at idle.
you can try cleaning the EGR valve too, if you have a scanner that can view live data, try watching your O2 sensor trims and voltages as well as cylinder specific misfire counts. and if you happen to also have a compression tester, that would be a good idea to check out as well.
after that, it could be so many things its really hard to say, anything from knife edging on the distributor gear, to poppets, to fuel pump, to wiring/electrical problems, to coil or ignition module, to internal engine issues, etc, etc, etc...