Well I got a PWM of the AVR to generate the 1MHz. I also always wait for the clock to be low to put new data on the bus.
I've fixed the detuning problem... The LCD PCB connecting on the same databus as the SID had 2 datalines shorted, so it was messing up everything. Tuning is good now, I can play a song but I still have this gating problem.
Here's the code I'm using. I won't detail now, it's only to see if I get the concept right. As you might guess, LoadSID loads the value at the defined register address (these are good, check them 3-4 times). ChipSelect is a macro to set the line decoder to the specified chip.
ChipSelectF()
LoadSID(ModeVol, 0x0F);
LoadSID(_2FreqLo, 0x81);
LoadSID(_2FreqHi, 0x19);
LoadSID(_2PWHi, 0x08);
LoadSID(_2PWLo, 0x80);
LoadSID(_2AttDec, 0x00);
LoadSID(_2SusRel, 0x00);
LoadSID(_2ControlReg, 0x20);
If I run this, I get a saw wave at the right frequency. Note that the gate bit is off AND the sustain is 0, but I still get full volume. The Mode/Volume register does work properly.
If I run the code selecting a 6581 on the same board, it works fine, except the fact the 6581 is alot quieter than the 8580.
I really do think the envelope generators are dead for some reason...