This is only designed to work on DOS. I have only tested compiling this with OpenWatcom v2.0. Open
to feedback on improving compiler compatibility.
This will look at the BLASTER environment variable for the base port, IRQ and DMA channel. We're
only allowing a single device to be initialized at any given time. The channel will be defined by
the BLASTER environment variable, or if that's not set, it will default to channel 1 (for 8-bit) or
channel 5 (for 16-bit).
*/
/* Keep this file empty if we're not compiling for DOS. */
#if defined(__MSDOS__) || defined(__DOS__)
#ifndef osaudio_dos_soundblaster_c
#define osaudio_dos_soundblaster_c
#include "osaudio.h"
#include <dos.h> /* outportb() */
#include <conio.h> /* delay() */
#include <string.h> /* memset() */
#include <stdlib.h> /* malloc(), free() */
intg_TESTING=0;
#define OSAUDIO_TIMEOUT_TICKS 18 /* ~1 second timeout (just under - runs at 18.2 ticks per second). Sound Blaster specs claim it should only take about 100 microseconds so this is way overkill. */
osaudio_config_tconfig;/* info.configs will point to this. */
unsignedintcursor;/* The position of the write or read cursor relative to the start of the current sub-buffer. In frames. */
unsignedcharsubBufferIndex;/* When 0, the next write and read will happen in the first half of the DMA buffer, when 1, the second half. Will flip-flop between 0 and 1 each interrupt. */
returnOSAUDIO_ERROR;/* Capture mode not supported. */
}
/* We're going to choose our native format configuration first. This way we can determine the Sound Blaster ports, channels and the size of the DMA buffer. */