Just had that Problem on my new to me 82 heritage.
After bulling what little hair i have left for a week, The Haynes Manuel was not helping me, its Mostly useless I've decided.
I Bought the Yamaha Service Manuel off Ebay for my XS650SJ (worth every Dollar).
They added a side stand switch and a relay that is also connected to the Neutral Switch.
If that relay is closed no Spark. To get spark the side stand needs to be up or the Tanny in Neutral so the relay will open.
My relay was stuck Closed, Thus no spark.
I Carefully opened up the relay and unstuck the points and cleaned them with fine sandpaper.
Moisture had gotten in there.
the Relay is on the left side, Follow the wires from the side stand switch.
if its working when the key is turned on and the side stand is up or in neutral it will click as it opens, turn the off the key it clicks as it closes.
Easy Fix If you have the right info.
Could be the side stand switch , Might need taken off and Clean.
Nice Safety Feature I wish my 81 had this.
Ron