The present SAA1099 emulator used by DOSBox, VGMPlay (from VGMRips.net), and likely MAME doesn't support proper envelope generator emulation. It is kind of
there, but I believe there is a bug in it's implementation (on how it gets activated). Once the envelope generator is enabled, the two ways to it either to use the internal envelope clock (setting bit 5 of registers 0x18 or 0x19 at 0) or via an external clock (bit 5 set to 1) as you mentioned above.
How to control the envelope generators is a bit different from most other chips as the usage effectively uses two channels (1&2 or 3&4) to control the envelope generator. One then has the option (via the mixer) and volume controls to mix in the square waveform on top of the envelope generator. Looking at the data sheet, first two waveforms seem useless, but actually can be used creatively in conjunction with the normal square waveform or the other envelope generator waveforms.
If you download Super Mario Bros.
and play any of the VGMs with SBVGM on real hardware, you will hear the triangle waveform.
To my knowledge there aren't any arcade VGMs or Gameblaster games that use the envelope generators or play back PCM samples on the SAA1099. Many of the music found on the Sam Coupe platform use the envelope generators or play back samples, but (so far) there aren't any VGMs captured from that platform.
Here are the register settings to enable the envelope generator (using the internal clock). The assumption is that the SAA1099 starts out with all it's registers cleared to 0.
- Code: Select all
REG : VALUE
0x1C: 0x01 ; sound enable
0x02: 0xFF ; set channel 2 amplitude
0x09: 0x3A ; set channel 1 frequency
0x10: 0x50 ; set channel 1 octave
0x18: 0x9A ; enable envelope generator 0, with internal clock & repeating triangle waveform with 3 bits for envelope control
The values above will activate envelope generator 0 and with only the triangle waveform audible. Frequency control of the envelope generators are done via channels 1 and 4 (for envelope generators 0 and 1 respectively).
Unfortunately with the present DOSBox SAA1099 emulator has a bug that the frequency enable bit for channel 2 or channel 5 have to be set in order for the envelope generator output to be audible ... which is not how the real hardware actually behaves. Enabling the frequency output on top of the envelope generator output naturally mixes the selected envelope generator waveform with the square waveform and one won't hear what one is initially expecting.
I'm really surprised that Creative Labs didn't document this feature in the C/MS programming manual. There are so many interesting things that can be done with the chip. At least the Sam Coupe scene managed to tap into some of it's power.
I have not had a chance to examine the source code, but if I find the problem spot before someone else does, I will let you know.