Grauw wrote:
"I know just the other day I did a experiment (rom attached) with PSG generating a pulse wave with duty cycle. In that experiment the MSX has to output volume changes in sync with the PSG, and the timing only worked correctly when I assumed 12 cycles for out instructions (tested on Yamaha CX5MII). Just a single cycle offset and it starts modulating audibly.
Though, running it on openMSX, there is some slight modulation present, so it seems that openMSX is off by a fraction of a cycle. Note that even if I deduct or add a cycle, it never becomes stable. Could be a little openMSX bug in PSG timing, or Z80 timing."
Counting the number of samples in the "record_channels PSG 1" dump, the period is set to exactly 256 so every wave should be 512 samples long... and for a few individual waves I looked at it this seemed to be correct, but looking at it over longer ranges it is not the case.
So it looks like the PSG is out of sync, not the Z80.
Source code paste + description will follow in a sec.
In this program I tried out the "SID effect", PSG waves with non-square duty cycle, as it’s used in many Atari ST trackers (though there it’s interrupt-driven).
It plays a square wave with the PSG, and then use the CPU to toggle the volume on and off at exactly the same rate with cycle-accurate timing, cutting off part of the wave.
I can't reproduce this anymore with the latest git HEAD. Can you confirm, grauw?
Fixed by ba9fcc4, props!
Indeed, thanks Wouter!