| Coincidentally I'm currently working on a Sound Blaster driver for some DOS homebrew, so here's quick rundown of how an SB is programmed and what its resources do: Base Address: This is the beginning of the IO port range you use to program the card, commonly it's 0x220, but can be configured with jumpers (or software on later cards). You can add offsets to this address to access different functionality of the card, such as the OPL chip or the Mixer chip. IRQ: The interrupt number that will be fired when the soundcard finishes playback of an audio chunk. Early cards usually used 7, later models defaulting to 5. More on this below. DMA Channel: Which channel of the PC's DMA controller will be supplying audio data to the card. Usually 1 for 8-bit cards, with 5 being used for 16-bit cards. The general process for playback is as follows: - Program the DMA controller with the address and size of an audio buffer you'll be using to mix your PCM sound into. This buffer will conventionally be used in 2 halves by the interrupt service routine, a front buffer and backbuffer, similar to what you'd have for double buffered video. The DMA channel should also be put in "auto-init" mode so that the DMA transfer will loop back to the start when it finishes, which allows continuous playback. - Install an interrupt service routine to write data into the "backbuffer" half of the DMA buffer, which switches back and forth each time an IRQ fires. - Initialize the DSP chip via its IO port, pick a sample rate (usually around 11khz for most DOS games), then issue a continuous playback command. For this part, you tell the soundcard that your playback buffer is half the size it actually is, which causes the IRQ to fire once in the middle of the buffer, and again at the end of the buffer before looping back to the start. These halfway IRQs allow you to fill the unused half of the buffer while the other half is playing, for smooth gapless playback with no clicks or pops. This is probably more info than you or anyone actually wanted, but it's a fun topic so I couldn't help myself. |
I thought the OPL chip was addressed via 388h (adlib/fm), not 220h (wave)?