|
Right, my driver changes the DMC frequency after each byte has played.
I'm assuming you've read http://www.slack.net/~ant/nes-emu/dmc_waves.html and http://www.slack.net/~ant/nes-emu/old_dmc_waves.html (it has more diagrams).
This method of generating waveforms requires a special driver; it's not just a particular DMC sample being looped. The driver serves two main purposes: change the DMC frequency after each byte (8 delta bits) plays, and periodically reset the DAC (for a saw wave) or switch between $00 and $ff samples (triangle wave).
There are tables of the DMC frequency combinations to use for a particular note. By having each cycle of the wave built from multiple samples played at different frequencies, I can get several octaves with fairly good accuracy, even though the base unit is limited to only 16 frequencies. The pictures show this clearly.
For the saw wave, the driver must reset the DAC ($4011) from 0 to full volume every n IRQs. For the triangle wave, every n IRQs it switches between the $00 and $ff sample values.
The saw and triangle waves use a constant-ramp sample is always being used; the steepness of the ramp is set by the current DMC frequency, rather than using a sample like $ee or $11. In the picture for the triangle wave, each 8-stairstep segment is playing at a different DMC frequency.
The asm source for the saw wave is there on the page. The modification for a triangle and square wave is trivial. I figured the quality of the latter two wasn't worth using in anything, since both waves are already available natively.
If you're adding support for DMC-based triangle and saw waves to MCK, I'd like help with the effort. E-mail me at mail.com.
|