/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Sound Blaster emulation.
*
* Authors: Sarah Walker,
* Miran Grca,
* TheCollector1995,
* Jasmine Iwanek,
* win2kgamer
*
* Copyright 2008-2020 Sarah Walker.
* Copyright 2016-2020 Miran Grca.
* Copyright 2024-2026 Jasmine Iwanek.
* Copyright 2026 win2kgamer
*/
#include
#include
#include
#include
#include
#include
#include
#define HAVE_STDARG_H
#include <86box/86box.h>
#include <86box/device.h>
#include <86box/filters.h>
#include <86box/gameport.h>
#include <86box/hdc.h>
#include <86box/isapnp.h>
#include <86box/hdc_ide.h>
#include <86box/io.h>
#include <86box/mca.h>
#include <86box/mem.h>
#include <86box/midi.h>
#include <86box/pic.h>
#include <86box/rom.h>
#include <86box/sound.h>
#include <86box/dma.h>
#include "cpu.h"
#include <86box/timer.h>
#include <86box/snd_sb.h>
#include <86box/plat_unused.h>
#include <86box/snd_azt2316a.h>
#define PNP_ROM_SB_16_PNP_NOIDE "roms/sound/creative/CT2941 PnP.BIN"
#define PNP_ROM_SB_16_PNP_IDE "roms/sound/creative/CTL0024A.BIN" /* CT2940 */
#define PNP_ROM_SB_VIBRA16C "roms/sound/creative/CT4180 PnP.BIN"
#define PNP_ROM_SB_VIBRA16CL "roms/sound/creative/CT4100 PnP.BIN"
#define PNP_ROM_SB_VIBRA16XV "roms/sound/creative/CT4170 PnP.BIN"
#define PNP_ROM_SB_GOLDFINCH "roms/sound/creative/CT1920 PnP.BIN"
#define PNP_ROM_SB_32_PNP "roms/sound/creative/CT3600 PnP.BIN"
#define PNP_ROM_SB_AWE32_PNP "roms/sound/creative/CT3980 PnP.BIN"
#define PNP_ROM_SB_AWE32_IDE_PNP "roms/sound/creative/CT3990 PnP.BIN"
#define PNP_ROM_SB_AWE64_VALUE "roms/sound/creative/CT4520 PnP.BIN"
#define PNP_ROM_SB_AWE64_NOIDE "roms/sound/creative/CT4380 PnP noIDE.BIN"
#define PNP_ROM_SB_AWE64_IDE "roms/sound/creative/CTL009DA.BIN" /* CT4381? */
#define PNP_ROM_SB_AWE64_GOLD "roms/sound/creative/CT4540 PnP.BIN"
/* TODO: Find real ESS PnP ROM dumps. */
#define PNP_ROM_ESS0100 "roms/sound/ess/ESS0100.BIN"
#define PNP_ROM_ESS0102 "roms/sound/ess/ESS0102.BIN"
#define PNP_ROM_ESS0968 "roms/sound/ess/ESS0968.BIN"
#define PNP_ROM_ESS1868 "roms/sound/ess/ESS1868.BIN"
#define PNP_ROM_ESS1869 "roms/sound/ess/ESS1869.BIN"
enum {
SB_1 = 0,
SB_15,
SB_2,
THUNDERBOARD
};
enum {
SB_16_PNP_NOIDE = 0,
SB_16_PNP_IDE
};
enum {
SB_VIBRA16XV = 0,
SB_VIBRA16C,
SB_VIBRA16CL
};
enum {
SB_32_PNP = 0,
SB_AWE32_PNP,
SB_AWE32_IDE_PNP,
SB_AWE64_VALUE,
SB_AWE64_NOIDE,
SB_AWE64_IDE,
SB_AWE64_GOLD
};
/* 0 to 7 -> -14dB to 0dB i 2dB steps. 8 to 15 -> 0 to +14dB in 2dB steps.
Note that for positive dB values, this is not amplitude, it is amplitude - 1. */
static const double sb_bass_treble_4bits[] = {
0.199526231, 0.25, 0.316227766, 0.398107170, 0.5, 0.63095734, 0.794328234, 1,
0, 0.25892541, 0.584893192, 1, 1.511886431, 2.16227766, 3, 4.011872336
};
/* Attenuation tables for the mixer. Max volume = 32767 in order to give 6dB of
* headroom and avoid integer overflow */
// clang-format off
static const double sb_att_2dbstep_5bits[] = {
25.0, 32.0, 41.0, 51.0, 65.0, 82.0, 103.0, 130.0, 164.0, 206.0,
260.0, 327.0, 412.0, 519.0, 653.0, 822.0, 1036.0, 1304.0, 1641.0, 2067.0,
2602.0, 3276.0, 4125.0, 5192.0, 6537.0, 8230.0, 10362.0, 13044.0, 16422.0, 20674.0,
26027.0, 32767.0
};
static const double sb_att_4dbstep_3bits[] = {
164.0, 2067.0, 3276.0, 5193.0, 8230.0, 13045.0, 20675.0, 32767.0
};
static const double sb_att_7dbstep_2bits[] = {
164.0, 6537.0, 14637.0, 32767.0
};
/* Attenuation table for ESS 4-bit microphone volume.
* The last step is a jump to -48 dB. */
static const double sb_att_1p4dbstep_4bits[] = {
164.0, 3431.0, 4031.0, 4736.0, 5565.0, 6537.0, 7681.0, 9025.0,
10603.0, 12458.0, 14637.0, 17196.0, 20204.0, 23738.0, 27889.0, 32767.0
};
/* Attenuation table for ESS 4-bit mixer volume.
* The last step is a jump to -48 dB. */
static const double sb_att_2dbstep_4bits[] = {
164.0, 1304.0, 1641.0, 2067.0, 2602.0, 3276.0, 4125.0, 5192.0,
6537.0, 8230.0, 10362.0, 13044.0, 16422.0, 20674.0, 26027.0, 32767.0
};
/* Attenuation table for ESS 3-bit PC speaker volume. */
static const double sb_att_3dbstep_3bits[] = {
0.0, 4125.0, 5826.0, 8230.0, 11626.0, 16422.0, 23197.0, 32767.0
};
// clang-format on
/* ES1788+ SBPro mixer emulation read translation table */
static const uint8_t ess_sbpro_6bit_xlat[] = {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x09, 0x09, 0x09, 0x09, 0x09, 0x0b, 0x0b, 0x0b, 0x0d, 0x0d, 0x0d, 0x0f, 0x0f
};
/* ES1788+ ESS legacy mixer read translation table */
static const uint8_t ess_6bit_xlat[] = {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03,
0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x07,
0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x09, 0x0a, 0x0a, 0x0b, 0x0c, 0x0c, 0x0d, 0x0e, 0x0f
};
/* ES1788+ mixer emulation write translation table */
static const uint8_t ess_4bit_xlat[] = {
0x00, 0x18, 0x1e, 0x22, 0x26, 0x2a, 0x2e, 0x32, 0x36, 0x37, 0x38, 0x3a, 0x3b, 0x3d, 0x3e, 0x3f
};
static double ess_att_6bits[64];
static double ess_input_gain_vols_4bits[16];
/*
* ES1938S Solo-1 playback-mixer curves (datasheet Table 22).
*
* The Solo-1 has separate gain curves for each audio source, so they have
* been separated out so as to not break existing AudioDrive mixers
*
* Entry 0 is mute and is handled explicitly by ess_solo1_4bit_gain().
*/
static const double ess_solo1_audio1_db[16] = {
0.0, -30.0, -27.0, -24.0, -21.0, -18.0, -15.0, -12.0,
-9.0, -7.5, -6.0, -4.5, -3.0, -1.5, 0.0, 1.5
};
static const double ess_solo1_audio2_db[16] = {
0.0, -31.5, -28.5, -25.5, -22.5, -19.5, -16.5, -13.5,
-10.5, -9.0, -7.5, -6.0, -4.5, -3.0, -1.5, 0.0
};
static const double ess_solo1_music_db[16] = {
0.0, -21.0, -18.0, -15.0, -12.0, -9.0, -6.0, -3.0,
0.0, 1.5, 3.0, 4.5, 6.0, 7.5, 9.0, 10.5
};
static const double ess_solo1_aux_db[16] = {
0.0, -28.5, -25.5, -22.5, -19.5, -16.5, -13.5, -10.5,
-7.5, -6.0, -4.5, -3.0, -1.5, 0.0, 1.5, 3.0
};
static double
ess_solo1_4bit_gain(const double table[16], uint8_t value)
{
value &= 0x0f;
if (value == 0)
return 0.0;
return pow(10.0, table[value] / 20.0);
}
static double
ess_solo1_master_gain(uint8_t value)
{
double db;
/* Bit 6 is mute; bits 5:0 are 0.75 dB steps, 3Fh = 0 dB. */
if (value & 0x40)
return 0.0;
db = -47.25 + (0.75 * (double) (value & 0x3f));
return pow(10.0, db / 20.0);
}
static const uint16_t sb_mcv_addr[8] = { 0x200, 0x210, 0x220, 0x230, 0x240, 0x250, 0x260, 0x270 };
static const int sb_pro_mcv_irqs[4] = { 7, 5, 3, 3 };
/* ES186x PnP key */
static const uint8_t es186x_pnp_key[] = {
0x66, 0xa1, 0xc2, 0xf1, 0xea, 0xe7, 0x71, 0xaa,
0xc7, 0x63, 0x33, 0x1b, 0x0d, 0x96, 0xdb, 0x6d,
0xa4, 0x50, 0x28, 0x16, 0x9b, 0x4d, 0xb6, 0xc9,
0xf4, 0x78, 0x3e, 0x8d, 0xd6, 0xfb, 0x7f, 0x3d
};
static const uint8_t es1868_header[] = { 0xA5, 0x59, 0xA7, 0xCB, 0x10, 0x53, 0x02, 0x0C };
#ifdef ENABLE_SB_LOG
int sb_do_log = ENABLE_SB_LOG;
static void
sb_log(const char *fmt, ...)
{
va_list ap;
if (sb_do_log) {
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
}
#else
# define sb_log(fmt, ...)
#endif
double low_fir_ess_dac2_coef[SB16_NCoef];
static __inline double
sinc(double x)
{
return sin(M_PI * x) / (M_PI * x);
}
static void
recalc_ess_dac2_filter(const int playback_freq)
{
/* Cutoff frequency = playback / 2 */
int n;
// const double fC = ((double) playback_freq) / (double) FREQ_96000;
const double fC = ((double) playback_freq) / (double) (sound_sample_rate << 1);
for (n = 0; n < SB16_NCoef; n++) {
/* Blackman window */
const double w = 0.42 - (0.5 * cos((2.0 * n * M_PI) / (double) (SB16_NCoef - 1))) +
(0.08 * cos((4.0 * n * M_PI) / (double) (SB16_NCoef - 1)));
/* Sinc filter */
const double h = sinc(2.0 * fC * ((double) n - ((double) (SB16_NCoef - 1) / 2.0)));
/* Create windowed-sinc filter */
low_fir_ess_dac2_coef[n] = w * h;
}
low_fir_ess_dac2_coef[(SB16_NCoef - 1) / 2] = 1.0;
double gain = 0.0;
for (n = 0; n < SB16_NCoef; n++)
gain += low_fir_ess_dac2_coef[n];
/* Normalise filter, to produce unity gain */
for (n = 0; n < SB16_NCoef; n++)
low_fir_ess_dac2_coef[n] /= gain;
}
/* SB 1, 1.5, MCV, and 2 do not have a mixer, so signal is hardwired. */
static void
sb_get_buffer_sb2(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
double out_mono;
sb_dsp_update(&sb->dsp);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
/* TODO: Recording: I assume it has direct mic and line in like SB2.
It is unclear from the docs if it has a filter, but it probably does. */
/* TODO: Recording: Mic and line In with AGC. */
if (sb->mixer_enabled)
out_mono = (sb_iir(0, 0, (double) sb->dsp.buffer[c]) * mixer->voice) / 3.9;
else
out_mono = (((sb_iir(0, 0, (double) sb->dsp.buffer[c]) / 1.3) * 65536.0) / 3.0) / 65536.0;
out_l += out_mono;
out_r += out_mono;
if (sb->mixer_enabled) {
out_l *= mixer->master;
out_r *= mixer->master;
}
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
sb->dsp.pos = 0;
}
static void
sb_get_cms_buffer_sb2(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
if (sb->cms_enabled)
cms_update(&sb->cms);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
if (sb->cms_enabled) {
out_l += sb->cms.buffer[c];
out_r += sb->cms.buffer[c + 1];
}
if (sb->cms_enabled && sb->mixer_enabled) {
out_l *= mixer->fm;
out_r *= mixer->fm;
}
if (sb->mixer_enabled) {
out_l *= mixer->master;
out_r *= mixer->master;
}
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
if (sb->cms_enabled)
sb->cms.pos = 0;
}
static void
sb_get_music_buffer_sb2(int32_t *buffer, uint16_t len, void *priv)
{
const sb_t *sb = (const sb_t *) priv;
const sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
const int32_t *opl_buf = NULL;
opl_buf = sb->opl.update(sb->opl.priv);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
const double out_mono = ((double) opl_buf[c]) * 0.7171630859375;
out_l += out_mono;
out_r += out_mono;
if (sb->mixer_enabled) {
out_l *= mixer->fm;
out_r *= mixer->fm;
}
if (sb->mixer_enabled) {
out_l *= mixer->master;
out_r *= mixer->master;
}
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
sb->opl.reset_buffer(sb->opl.priv);
}
static void
sb2_filter_cd_audio(UNUSED(int channel), double *buffer, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
double c;
if (sb->mixer_enabled) {
c = ((sb_iir(2, 0, *buffer) / 1.3) * mixer->cd) / 3.0;
*buffer = c * mixer->master;
} else {
c = (((sb_iir(2, 0, (*buffer)) / 1.3) * 65536) / 3.0) / 65536.0;
*buffer = c;
}
}
void
sb_get_buffer_sbpro(int32_t *buffer, const uint16_t len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
sb_dsp_update(&sb->dsp);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
/* TODO: Implement the stereo switch on the mixer instead of on the dsp? */
if (mixer->output_filter) {
out_l += (sb_iir(0, 0, (double) sb->dsp.buffer[c]) * mixer->voice_l) / 3.9;
out_r += (sb_iir(0, 1, (double) sb->dsp.buffer[c + 1]) * mixer->voice_r) / 3.9;
} else {
out_l += (sb->dsp.buffer[c] * mixer->voice_l) / 3.0;
out_r += (sb->dsp.buffer[c + 1] * mixer->voice_r) / 3.0;
}
/* TODO: recording CD, Mic with AGC or line in. Note: mic volume does not affect recording. */
out_l *= mixer->master_l;
out_r *= mixer->master_r;
/* Output gain required for the Pro Sonic 16 so PCM sounds are volume adjusted
to similar levels produced by the external midi and PC speaker */
if (IS_MV1216(&sb->dsp)) {
out_l *= sb->mvd_1216_output_gain;
out_r *= sb->mvd_1216_output_gain;
}
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
sb->dsp.pos = 0;
}
void
sb_get_music_buffer_sbpro(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
double out_l = 0.0;
double out_r = 0.0;
const int32_t *opl_buf = NULL;
const int32_t *opl2_buf = NULL;
if (!sb->opl_enabled)
return;
opl_buf = sb->opl.update(sb->opl.priv);
if (sb->has_dualopl2)
opl2_buf = sb->opl2.update(sb->opl2.priv);
sb_dsp_update(&sb->dsp);
for (uint16_t c = 0; c < len * 2; c += 2) {
out_l = 0.0;
out_r = 0.0;
if (sb->has_dualopl2) {
/* Two chips for LEFT and RIGHT channels.
Each chip stores data into the LEFT channel only (no sample alternating.) */
out_l = (((double) opl_buf[c]) * mixer->fm_l) * 0.7171630859375;
if (opl2_buf != NULL)
out_r = (((double) opl2_buf[c]) * mixer->fm_r) * 0.7171630859375;
} else {
out_l = (((double) opl_buf[c]) * mixer->fm_l) * 0.7171630859375;
out_r = (((double) opl_buf[c + 1]) * mixer->fm_r) * 0.7171630859375;
if (sb->opl_mix && sb->opl_mixer)
sb->opl_mix(sb->opl_mixer, &out_l, &out_r);
}
/* TODO: recording CD, Mic with AGC or line in. Note: mic volume does not affect recording. */
out_l *= mixer->master_l;
out_r *= mixer->master_r;
/* Output gain required for the Pro Sonic 16 so PCM sounds are volume adjusted
to similar levels produced by the external midi and PC speaker */
if (IS_MV1216(&sb->dsp)) {
out_l *= sb->mvd_1216_output_gain;
out_r *= sb->mvd_1216_output_gain;
}
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
sb->opl.reset_buffer(sb->opl.priv);
if (sb->dsp.sb_type == SBPRO_DSP_300)
sb->opl2.reset_buffer(sb->opl2.priv);
}
void
sbpro_filter_cd_audio(int channel, double *buffer, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
const double cd = channel ? mixer->cd_r : mixer->cd_l;
const double master = channel ? mixer->master_r : mixer->master_l;
double c = ((*buffer * cd) / 3.0) * master;
/* Output gain required for the Pro Sonic 16 so CDDA music is volume adjusted
to similar levels produced by the external midi and PC speaker */
if (IS_MV1216(&sb->dsp))
c *= sb->mvd_1216_output_gain;
*buffer = c;
}
static void
sb_get_buffer_sb16_awe32(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
double bass_treble;
sb_dsp_update(&sb->dsp);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
if (mixer->output_filter) {
/* We divide by 3 to get the volume down to normal. */
out_l += (low_fir_sb16(0, (double) sb->dsp.buffer[c]) * mixer->voice_l) / 3.0;
out_r += (low_fir_sb16(1, (double) sb->dsp.buffer[c + 1]) * mixer->voice_r) / 3.0;
} else {
out_l += (((double) sb->dsp.buffer[c]) * mixer->voice_l) / 3.0;
out_r += (((double) sb->dsp.buffer[c + 1]) * mixer->voice_r) / 3.0;
}
out_l *= mixer->master_l;
out_r *= mixer->master_r;
/* This is not exactly how one does bass/treble controls, but the end result is like it.
A better implementation would reduce the CPU usage. */
if (mixer->bass_l != 8) {
bass_treble = sb_bass_treble_4bits[mixer->bass_l];
if (mixer->bass_l > 8)
out_l += (low_iir(0, 0, out_l) * bass_treble);
else
out_l = (out_l *bass_treble + low_cut_iir(0, 0, out_l) * (1.0 - bass_treble));
}
if (mixer->bass_r != 8) {
bass_treble = sb_bass_treble_4bits[mixer->bass_r];
if (mixer->bass_r > 8)
out_r += (low_iir(0, 1, out_r) * bass_treble);
else
out_r = (out_r *bass_treble + low_cut_iir(0, 1, out_r) * (1.0 - bass_treble));
}
if (mixer->treble_l != 8) {
bass_treble = sb_bass_treble_4bits[mixer->treble_l];
if (mixer->treble_l > 8)
out_l += (high_iir(0, 0, out_l) * bass_treble);
else
out_l = (out_l *bass_treble + high_cut_iir(0, 0, out_l) * (1.0 - bass_treble));
}
if (mixer->treble_r != 8) {
bass_treble = sb_bass_treble_4bits[mixer->treble_r];
if (mixer->treble_r > 8)
out_r += (high_iir(0, 1, out_r) * bass_treble);
else
out_r = (out_r *bass_treble + high_cut_iir(0, 1, out_r) * (1.0 - bass_treble));
}
buffer[c] += (int32_t) (out_l * mixer->output_gain_L);
buffer[c + 1] += (int32_t) (out_r * mixer->output_gain_R);
}
sb->dsp.pos = 0;
}
#define SB_RECORD_CLAMP(x) (((x) < -32768) ? -32768 : (((x) > 32767) ? 32767 : (x)))
/* filter when sb_freq < capture rate */
#define SB_RECORD_ANTIALIAS 1
/* nyquist anti alias */
#define SB_RECORD_AA_NYQ 0.9
/* audio filter called on filter rate change */
static void
sb_record_aa_design(sb_dsp_t *dsp, int out_rate, int in_rate)
{
const double fc = (SB_RECORD_AA_NYQ * 0.5) * ((double) out_rate);
const double w0 = (2.0 * M_PI * fc) / ((double) in_rate);
const double cw = cos(w0);
const double sw = sin(w0);
const double alpha = sw / (2.0 * 0.70710678118654752);
const double a0 = 1.0 + alpha;
dsp->record_aa_b0_mic = ((1.0 - cw) / 2.0) / a0;
dsp->record_aa_b1_mic = (1.0 - cw) / a0;
dsp->record_aa_b2_mic = dsp->record_aa_b0_mic;
dsp->record_aa_a1_mic = (-2.0 * cw) / a0;
dsp->record_aa_a2_mic = (1.0 - alpha) / a0;
}
static double
sb_record_aa_step(sb_dsp_t *dsp, int ch, double x)
{
const double y = (dsp->record_aa_b0_mic * x) + dsp->record_aa_z1_mic[ch];
dsp->record_aa_z1_mic[ch] = (dsp->record_aa_b1_mic * x) - (dsp->record_aa_a1_mic * y)
+ dsp->record_aa_z2_mic[ch];
dsp->record_aa_z2_mic[ch] = (dsp->record_aa_b2_mic * x) - (dsp->record_aa_a2_mic * y);
return y;
}
static void
ess_put_buffer_esx488(int16_t *buffer, int len, void *priv)
{
sb_t *ess = (sb_t *) priv;
/* divisor is rate capture device opened at*/
const int cap_rate = al_capture_get_rate();
const int denom = (cap_rate > 0) ? cap_rate : SOUND_FREQ;
const int rate = ess->dsp.sb_freq;
int c;
int gain;
int interp;
int filt;
/* sb_freq is 0 until the guest programs a rate */
if (rate <= 0)
return;
if ((denom != ess->dsp.record_denom_mic) || (rate != ess->dsp.record_rate_mic)) {
ess->dsp.record_denom_mic = denom;
ess->dsp.record_rate_mic = rate;
ess->dsp.record_phase_mic = 0;
ess->dsp.record_prev_l_mic = 0;
ess->dsp.record_prev_r_mic = 0;
ess->dsp.record_prev_valid_mic = 0;
ess->dsp.record_aa_z1_mic[0] = 0.0;
ess->dsp.record_aa_z1_mic[1] = 0.0;
ess->dsp.record_aa_z2_mic[0] = 0.0;
ess->dsp.record_aa_z2_mic[1] = 0.0;
ess->dsp.record_aa_active_mic = 0;
#if SB_RECORD_ANTIALIAS
/* only when decimating */
if (rate < denom) {
sb_record_aa_design(&ess->dsp, rate, denom);
ess->dsp.record_aa_active_mic = 1;
}
#endif
}
interp = (rate != denom);
filt = ess->dsp.record_aa_active_mic;
gain = ess->dsp.ess_input_gain;
for (c = 0; c < len * 2; c += 2) {
const int32_t cap_l = (int32_t) buffer[c];
const int32_t cap_r = (int32_t) buffer[c + 1];
/* mic is the mono sum of line-in. truncating division for dc symmetry */
const int32_t mic = (cap_l + cap_r) / 2;
int32_t mix_l = mic;
int32_t mix_r = mic;
int32_t in_l;
int32_t in_r;
/* run on every input frame*/
if (filt) {
mix_l = (int32_t) lrint(sb_record_aa_step(&ess->dsp, 0, (double) mix_l));
mix_r = (int32_t) lrint(sb_record_aa_step(&ess->dsp, 1, (double) mix_r));
}
in_l = SB_RECORD_CLAMP(mix_l * ess_input_gain_vols_4bits[gain]);
in_r = SB_RECORD_CLAMP(mix_r * ess_input_gain_vols_4bits[gain]);
/* start new device change with first frame in interpolartor queue */
if (!ess->dsp.record_prev_valid_mic) {
ess->dsp.record_prev_l_mic = in_l;
ess->dsp.record_prev_r_mic = in_r;
ess->dsp.record_prev_valid_mic = 1;
}
/* phase ticks this forward, while-loop for new samples so they arent dropped */
ess->dsp.record_phase_mic += rate;
while (ess->dsp.record_phase_mic >= denom) {
int32_t out_l;
int32_t out_r;
ess->dsp.record_phase_mic -= denom; /* denom tracks input frame vs emitted frame , (rate - phase) / rate */
if (interp) {
const int32_t num = rate - ess->dsp.record_phase_mic;
out_l = ess->dsp.record_prev_l_mic
+ (int32_t) ((((int64_t) (in_l - ess->dsp.record_prev_l_mic)) * num) / rate);
out_r = ess->dsp.record_prev_r_mic
+ (int32_t) ((((int64_t) (in_r - ess->dsp.record_prev_r_mic)) * num) / rate);
} else {
out_l = in_l;
out_r = in_r;
}
ess->dsp.record_buffer[ess->dsp.record_pos_write_mic] = (int16_t) out_l;
ess->dsp.record_buffer[(ess->dsp.record_pos_write_mic + 1) & 0xffff] = (int16_t) out_r;
ess->dsp.record_pos_write_mic = (ess->dsp.record_pos_write_mic + 2) & 0xffff;
}
ess->dsp.record_prev_l_mic = in_l;
ess->dsp.record_prev_r_mic = in_r;
}
}
void
ess_put_buffer(int16_t *buffer, int len, void *priv)
{
sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
/* divisor is rate capture device opened at*/
const int cap_rate = al_capture_get_rate();
const int denom = (cap_rate > 0) ? cap_rate : SOUND_FREQ;
const int rate = ess->dsp.sb_freq;
int c;
int gain_l;
int gain_r;
int sel_mic, sel_line;
int interp;
int filt;
/* sb_freq is 0 until the guest programs a rate */
if (rate <= 0)
return;
if ((denom != ess->dsp.record_denom_mic) || (rate != ess->dsp.record_rate_mic)) {
ess->dsp.record_denom_mic = denom;
ess->dsp.record_rate_mic = rate;
ess->dsp.record_phase_mic = 0;
ess->dsp.record_prev_l_mic = 0;
ess->dsp.record_prev_r_mic = 0;
ess->dsp.record_prev_valid_mic = 0;
ess->dsp.record_aa_z1_mic[0] = 0.0;
ess->dsp.record_aa_z1_mic[1] = 0.0;
ess->dsp.record_aa_z2_mic[0] = 0.0;
ess->dsp.record_aa_z2_mic[1] = 0.0;
ess->dsp.record_aa_active_mic = 0;
#if SB_RECORD_ANTIALIAS
/* only when decimating */
if (rate < denom) {
sb_record_aa_design(&ess->dsp, rate, denom);
ess->dsp.record_aa_active_mic = 1;
}
#endif
}
interp = (rate != denom);
filt = ess->dsp.record_aa_active_mic;
gain_l = ess->dsp.ess_input_gain_l;
gain_r = ess->dsp.ess_input_gain_r;
sel_mic = (mixer->input_selector == INPUT_MIC) != 0;
sel_line = ((mixer->input_selector & INPUT_LINE_L) != 0) || ((mixer->input_selector & INPUT_MIXER_L) != 0);
for (c = 0; c < len * 2; c += 2) {
const int32_t cap_l = (int32_t) buffer[c];
const int32_t cap_r = (int32_t) buffer[c + 1];
/* mic is the mono sum of line-in. truncating division for dc symmetry */
const int32_t mic = (cap_l + cap_r) / 2;
int32_t mix_l = (mic * sel_mic) + (cap_l * sel_line);
int32_t mix_r = (mic * sel_mic) + (cap_r * sel_line);
int32_t in_l;
int32_t in_r;
/* run on every input frame*/
if (filt) {
mix_l = (int32_t) lrint(sb_record_aa_step(&ess->dsp, 0, (double) mix_l));
mix_r = (int32_t) lrint(sb_record_aa_step(&ess->dsp, 1, (double) mix_r));
}
in_l = SB_RECORD_CLAMP(mix_l * ess_input_gain_vols_4bits[gain_l]);
in_r = SB_RECORD_CLAMP(mix_r * ess_input_gain_vols_4bits[gain_r]);
/* start new device change with first frame in interpolartor queue */
if (!ess->dsp.record_prev_valid_mic) {
ess->dsp.record_prev_l_mic = in_l;
ess->dsp.record_prev_r_mic = in_r;
ess->dsp.record_prev_valid_mic = 1;
}
/* phase ticks this forward, while-loop for new samples so they arent dropped */
ess->dsp.record_phase_mic += rate;
while (ess->dsp.record_phase_mic >= denom) {
int32_t out_l;
int32_t out_r;
ess->dsp.record_phase_mic -= denom; /* denom tracks input frame vs emitted frame , (rate - phase) / rate */
if (interp) {
const int32_t num = rate - ess->dsp.record_phase_mic;
out_l = ess->dsp.record_prev_l_mic
+ (int32_t) ((((int64_t) (in_l - ess->dsp.record_prev_l_mic)) * num) / rate);
out_r = ess->dsp.record_prev_r_mic
+ (int32_t) ((((int64_t) (in_r - ess->dsp.record_prev_r_mic)) * num) / rate);
} else {
out_l = in_l;
out_r = in_r;
}
ess->dsp.record_buffer[ess->dsp.record_pos_write_mic] = (int16_t) out_l;
ess->dsp.record_buffer[(ess->dsp.record_pos_write_mic + 1) & 0xffff] = (int16_t) out_r;
ess->dsp.record_pos_write_mic = (ess->dsp.record_pos_write_mic + 2) & 0xffff;
}
ess->dsp.record_prev_l_mic = in_l;
ess->dsp.record_prev_r_mic = in_r;
}
}
static void
sb_put_buffer_sb(int16_t *buffer, int len, void *priv)
{
sb_t *sb = (sb_t *) priv;
/* divisor is rate capture device opened at*/
const int cap_rate = al_capture_get_rate();
const int denom = (cap_rate > 0) ? cap_rate : SOUND_FREQ;
const int rate = sb->dsp.sb_freq;
int c;
int interp;
int filt;
/* sb_freq is 0 until the guest programs a rate */
if (rate <= 0)
return;
if ((denom != sb->dsp.record_denom_mic) || (rate != sb->dsp.record_rate_mic)) {
sb->dsp.record_denom_mic = denom;
sb->dsp.record_rate_mic = rate;
sb->dsp.record_phase_mic = 0;
sb->dsp.record_prev_l_mic = 0;
sb->dsp.record_prev_r_mic = 0;
sb->dsp.record_prev_valid_mic = 0;
sb->dsp.record_aa_z1_mic[0] = 0.0;
sb->dsp.record_aa_z1_mic[1] = 0.0;
sb->dsp.record_aa_z2_mic[0] = 0.0;
sb->dsp.record_aa_z2_mic[1] = 0.0;
sb->dsp.record_aa_active_mic = 0;
#if SB_RECORD_ANTIALIAS
/* only when decimating */
if (rate < denom) {
sb_record_aa_design(&sb->dsp, rate, denom);
sb->dsp.record_aa_active_mic = 1;
}
#endif
}
interp = (rate != denom);
filt = sb->dsp.record_aa_active_mic;
for (c = 0; c < len * 2; c += 2) {
const int32_t cap_l = (int32_t) buffer[c];
const int32_t cap_r = (int32_t) buffer[c + 1];
/* mic is the mono sum of line-in. truncating division for dc symmetry */
const int32_t mic = (cap_l + cap_r) / 2;
int32_t mix_l = mic;
int32_t mix_r = mic;
int32_t in_l;
int32_t in_r;
/* run on every input frame*/
if (filt) {
mix_l = (int32_t) lrint(sb_record_aa_step(&sb->dsp, 0, (double) mix_l));
mix_r = (int32_t) lrint(sb_record_aa_step(&sb->dsp, 1, (double) mix_r));
}
in_l = SB_RECORD_CLAMP(mix_l * 2);
in_r = SB_RECORD_CLAMP(mix_r * 2);
/* start new device change with first frame in interpolartor queue */
if (!sb->dsp.record_prev_valid_mic) {
sb->dsp.record_prev_l_mic = in_l;
sb->dsp.record_prev_r_mic = in_r;
sb->dsp.record_prev_valid_mic = 1;
}
/* phase ticks this forward, while-loop for new samples so they arent dropped */
sb->dsp.record_phase_mic += rate;
while (sb->dsp.record_phase_mic >= denom) {
int32_t out_l;
int32_t out_r;
sb->dsp.record_phase_mic -= denom; /* denom tracks input frame vs emitted frame , (rate - phase) / rate */
if (interp) {
const int32_t num = rate - sb->dsp.record_phase_mic;
out_l = sb->dsp.record_prev_l_mic
+ (int32_t) ((((int64_t) (in_l - sb->dsp.record_prev_l_mic)) * num) / rate);
out_r = sb->dsp.record_prev_r_mic
+ (int32_t) ((((int64_t) (in_r - sb->dsp.record_prev_r_mic)) * num) / rate);
} else {
out_l = in_l;
out_r = in_r;
}
sb->dsp.record_buffer[sb->dsp.record_pos_write_mic] = (int16_t) out_l;
sb->dsp.record_buffer[(sb->dsp.record_pos_write_mic + 1) & 0xffff] = (int16_t) out_r;
sb->dsp.record_pos_write_mic = (sb->dsp.record_pos_write_mic + 2) & 0xffff;
}
sb->dsp.record_prev_l_mic = in_l;
sb->dsp.record_prev_r_mic = in_r;
}
}
void
sb_put_buffer_sbpro(int16_t *buffer, int len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
/* divisor is rate capture device opened at*/
const int cap_rate = al_capture_get_rate();
const int denom = (cap_rate > 0) ? cap_rate : SOUND_FREQ;
const int rate = sb->dsp.sb_freq;
int c;
int sel_mic, sel_line;
int interp;
int filt;
/* sb_freq is 0 until the guest programs a rate */
if (rate <= 0)
return;
if ((denom != sb->dsp.record_denom_mic) || (rate != sb->dsp.record_rate_mic)) {
sb->dsp.record_denom_mic = denom;
sb->dsp.record_rate_mic = rate;
sb->dsp.record_phase_mic = 0;
sb->dsp.record_prev_l_mic = 0;
sb->dsp.record_prev_r_mic = 0;
sb->dsp.record_prev_valid_mic = 0;
sb->dsp.record_aa_z1_mic[0] = 0.0;
sb->dsp.record_aa_z1_mic[1] = 0.0;
sb->dsp.record_aa_z2_mic[0] = 0.0;
sb->dsp.record_aa_z2_mic[1] = 0.0;
sb->dsp.record_aa_active_mic = 0;
#if SB_RECORD_ANTIALIAS
/* only when decimating */
if (rate < denom) {
sb_record_aa_design(&sb->dsp, rate, denom);
sb->dsp.record_aa_active_mic = 1;
}
#endif
}
interp = (rate != denom);
filt = sb->dsp.record_aa_active_mic;
sel_mic = (mixer->input_selector == INPUT_MIC) != 0;
sel_line = (mixer->input_selector & INPUT_LINE_L) != 0;
for (c = 0; c < len * 2; c += 2) {
const int32_t cap_l = (int32_t) buffer[c];
const int32_t cap_r = (int32_t) buffer[c + 1];
/* mic is the mono sum of line-in. truncating division for dc symmetry */
const int32_t mic = (cap_l + cap_r) / 2;
int32_t mix_l = (mic * sel_mic) + (cap_l * sel_line);
int32_t mix_r = (mic * sel_mic) + (cap_r * sel_line);
int32_t in_l;
int32_t in_r;
/* run on every input frame*/
if (filt) {
mix_l = (int32_t) lrint(sb_record_aa_step(&sb->dsp, 0, (double) mix_l));
mix_r = (int32_t) lrint(sb_record_aa_step(&sb->dsp, 1, (double) mix_r));
}
in_l = SB_RECORD_CLAMP(mix_l * 2);
in_r = SB_RECORD_CLAMP(mix_r * 2);
/* start new device change with first frame in interpolartor queue */
if (!sb->dsp.record_prev_valid_mic) {
sb->dsp.record_prev_l_mic = in_l;
sb->dsp.record_prev_r_mic = in_r;
sb->dsp.record_prev_valid_mic = 1;
}
/* phase ticks this forward, while-loop for new samples so they arent dropped */
sb->dsp.record_phase_mic += rate;
while (sb->dsp.record_phase_mic >= denom) {
int32_t out_l;
int32_t out_r;
sb->dsp.record_phase_mic -= denom; /* denom tracks input frame vs emitted frame , (rate - phase) / rate */
if (interp) {
const int32_t num = rate - sb->dsp.record_phase_mic;
out_l = sb->dsp.record_prev_l_mic
+ (int32_t) ((((int64_t) (in_l - sb->dsp.record_prev_l_mic)) * num) / rate);
out_r = sb->dsp.record_prev_r_mic
+ (int32_t) ((((int64_t) (in_r - sb->dsp.record_prev_r_mic)) * num) / rate);
} else {
out_l = in_l;
out_r = in_r;
}
if (sb->dsp.stereoi) {
if (!sb->dsp.sbleftrighti) {
sb->dsp.record_buffer[sb->dsp.record_pos_write_mic] = (int16_t) out_l;
sb->dsp.record_buffer[(sb->dsp.record_pos_write_mic + 1) & 0xffff] = (int16_t) out_r;
sb->dsp.record_pos_write_mic = (sb->dsp.record_pos_write_mic + 2) & 0xffff;
} else {
sb->dsp.record_buffer[sb->dsp.record_pos_write_mic] = (int16_t) out_r;
sb->dsp.record_buffer[(sb->dsp.record_pos_write_mic + 1) & 0xffff] = (int16_t) out_l;
sb->dsp.record_pos_write_mic = (sb->dsp.record_pos_write_mic + 2) & 0xffff;
}
sb->dsp.sbleftrighti = !sb->dsp.sbleftrighti;
} else {
sb->dsp.record_buffer[sb->dsp.record_pos_write_mic] = (int16_t) out_l;
sb->dsp.record_buffer[(sb->dsp.record_pos_write_mic + 1) & 0xffff] = (int16_t) out_r;
sb->dsp.record_pos_write_mic = (sb->dsp.record_pos_write_mic + 2) & 0xffff;
}
}
sb->dsp.record_prev_l_mic = in_l;
sb->dsp.record_prev_r_mic = in_r;
}
}
static void
sb_put_buffer_sb16_awe32(int16_t *buffer, int len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
/* divisor is rate capture device opened at*/
const int cap_rate = al_capture_get_rate();
const int denom = (cap_rate > 0) ? cap_rate : SOUND_FREQ;
const int rate = sb->dsp.sb_freq;
int c;
int gain_l;
int gain_r;
int sel_l_mic, sel_l_linel, sel_l_liner;
int sel_r_mic, sel_r_linel, sel_r_liner;
int interp;
int filt;
/* sb_freq is 0 until the guest programs a rate */
if (rate <= 0)
return;
if ((denom != sb->dsp.record_denom_mic) || (rate != sb->dsp.record_rate_mic)) {
sb->dsp.record_denom_mic = denom;
sb->dsp.record_rate_mic = rate;
sb->dsp.record_phase_mic = 0;
sb->dsp.record_prev_l_mic = 0;
sb->dsp.record_prev_r_mic = 0;
sb->dsp.record_prev_valid_mic = 0;
sb->dsp.record_aa_z1_mic[0] = 0.0;
sb->dsp.record_aa_z1_mic[1] = 0.0;
sb->dsp.record_aa_z2_mic[0] = 0.0;
sb->dsp.record_aa_z2_mic[1] = 0.0;
sb->dsp.record_aa_active_mic = 0;
#if SB_RECORD_ANTIALIAS
/* only when decimating */
if (rate < denom) {
sb_record_aa_design(&sb->dsp, rate, denom);
sb->dsp.record_aa_active_mic = 1;
}
#endif
}
interp = (rate != denom);
filt = sb->dsp.record_aa_active_mic;
gain_l = 1 << mixer->input_gain_L;
gain_r = 1 << mixer->input_gain_R;
sel_l_mic = (mixer->input_selector_left & INPUT_MIC) != 0;
sel_l_linel = (mixer->input_selector_left & INPUT_LINE_L) != 0;
sel_l_liner = (mixer->input_selector_left & INPUT_LINE_R) != 0;
sel_r_mic = (mixer->input_selector_right & INPUT_MIC) != 0;
sel_r_linel = (mixer->input_selector_right & INPUT_LINE_L) != 0;
sel_r_liner = (mixer->input_selector_right & INPUT_LINE_R) != 0;
for (c = 0; c < len * 2; c += 2) {
const int32_t cap_l = (int32_t) buffer[c];
const int32_t cap_r = (int32_t) buffer[c + 1];
/* mic is the mono sum of line-in. truncating division for dc symmetry */
const int32_t mic = (cap_l + cap_r) / 2;
int32_t mix_l = (mic * sel_l_mic) + (cap_l * sel_l_linel) + (cap_r * sel_l_liner);
int32_t mix_r = (mic * sel_r_mic) + (cap_l * sel_r_linel) + (cap_r * sel_r_liner);
int32_t in_l;
int32_t in_r;
/* run on every input frame*/
if (filt) {
mix_l = (int32_t) lrint(sb_record_aa_step(&sb->dsp, 0, (double) mix_l));
mix_r = (int32_t) lrint(sb_record_aa_step(&sb->dsp, 1, (double) mix_r));
}
in_l = SB_RECORD_CLAMP(mix_l * gain_l);
in_r = SB_RECORD_CLAMP(mix_r * gain_r);
/* start new device change with first frame in interpolartor queue */
if (!sb->dsp.record_prev_valid_mic) {
sb->dsp.record_prev_l_mic = in_l;
sb->dsp.record_prev_r_mic = in_r;
sb->dsp.record_prev_valid_mic = 1;
}
/* phase ticks this forward, while-loop for new samples so they arent dropped */
sb->dsp.record_phase_mic += rate;
while (sb->dsp.record_phase_mic >= denom) {
int32_t out_l;
int32_t out_r;
sb->dsp.record_phase_mic -= denom; /* denom tracks input frame vs emitted frame , (rate - phase) / rate */
if (interp) {
const int32_t num = rate - sb->dsp.record_phase_mic;
out_l = sb->dsp.record_prev_l_mic
+ (int32_t) ((((int64_t) (in_l - sb->dsp.record_prev_l_mic)) * num) / rate);
out_r = sb->dsp.record_prev_r_mic
+ (int32_t) ((((int64_t) (in_r - sb->dsp.record_prev_r_mic)) * num) / rate);
} else {
out_l = in_l;
out_r = in_r;
}
sb->dsp.record_buffer[sb->dsp.record_pos_write_mic] = (int16_t) out_l;
sb->dsp.record_buffer[(sb->dsp.record_pos_write_mic + 1) & 0xffff] = (int16_t) out_r;
sb->dsp.record_pos_write_mic = (sb->dsp.record_pos_write_mic + 2) & 0xffff;
}
sb->dsp.record_prev_l_mic = in_l;
sb->dsp.record_prev_r_mic = in_r;
}
}
static void
sb_get_music_buffer_sb16_awe32(int32_t *buffer, const uint16_t len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
const int dsp_rec_pos = sb->dsp.record_pos_write;
double bass_treble;
const int32_t *opl_buf = NULL;
if (sb->opl_enabled)
opl_buf = sb->opl.update(sb->opl.priv);
for (int c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
if (sb->opl_enabled) {
out_l = ((double) opl_buf[c]) * mixer->fm_l * 0.7171630859375;
out_r = ((double) opl_buf[c + 1]) * mixer->fm_r * 0.7171630859375;
}
/* TODO: Multi-recording mic with agc/+20db, CD, and line in with channel inversion */
int32_t in_l = (mixer->input_selector_left & INPUT_MIDI_L) ?
((int32_t) out_l) : 0 + (mixer->input_selector_left & INPUT_MIDI_R) ? ((int32_t) out_r) : 0;
int32_t in_r = (mixer->input_selector_right & INPUT_MIDI_L) ?
((int32_t) out_l) : 0 + (mixer->input_selector_right & INPUT_MIDI_R) ? ((int32_t) out_r) : 0;
out_l *= mixer->master_l;
out_r *= mixer->master_r;
/* This is not exactly how one does bass/treble controls, but the end result is like it.
A better implementation would reduce the CPU usage. */
if (mixer->bass_l != 8) {
bass_treble = sb_bass_treble_4bits[mixer->bass_l];
if (mixer->bass_l > 8)
out_l += (low_iir(1, 0, out_l) * bass_treble);
else
out_l = (out_l *bass_treble + low_cut_iir(1, 0, out_l) * (1.0 - bass_treble));
}
if (mixer->bass_r != 8) {
bass_treble = sb_bass_treble_4bits[mixer->bass_r];
if (mixer->bass_r > 8)
out_r += (low_iir(1, 1, out_r) * bass_treble);
else
out_r = (out_r *bass_treble + low_cut_iir(1, 1, out_r) * (1.0 - bass_treble));
}
if (mixer->treble_l != 8) {
bass_treble = sb_bass_treble_4bits[mixer->treble_l];
if (mixer->treble_l > 8)
out_l += (high_iir(1, 0, out_l) * bass_treble);
else
out_l = (out_l *bass_treble + high_cut_iir(1, 0, out_l) * (1.0 - bass_treble));
}
if (mixer->treble_r != 8) {
bass_treble = sb_bass_treble_4bits[mixer->treble_r];
if (mixer->treble_r > 8)
out_r += (high_iir(1, 1, out_r) * bass_treble);
else
out_r = (out_r *bass_treble + high_cut_iir(1, 1, out_r) * (1.0 - bass_treble));
}
if (sb->dsp.sb_enable_i) {
const int c_record = dsp_rec_pos + ((c * sb->dsp.sb_freq) / MUSIC_FREQ);
in_l <<= mixer->input_gain_L;
in_r <<= mixer->input_gain_R;
/* Clip signal */
if (in_l < -32768)
in_l = -32768;
else if (in_l > 32767)
in_l = 32767;
if (in_r < -32768)
in_r = -32768;
else if (in_r > 32767)
in_r = 32767;
sb->dsp.record_buffer[c_record & 0xffff] = (int16_t) in_l;
sb->dsp.record_buffer[(c_record + 1) & 0xffff] = (int16_t) in_r;
}
buffer[c] += (int32_t) (out_l * mixer->output_gain_L);
buffer[c + 1] += (int32_t) (out_r * mixer->output_gain_R);
}
sb->dsp.record_pos_write += ((len * sb->dsp.sb_freq) / 24000);
sb->dsp.record_pos_write &= 0xffff;
if (sb->opl_enabled)
sb->opl.reset_buffer(sb->opl.priv);
}
static void
sb_get_wavetable_buffer_goldfinch(int32_t *buffer, const uint16_t len, void *priv)
{
goldfinch_t *goldfinch = (goldfinch_t *) priv;
emu8k_update(&goldfinch->emu8k);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
out_l += ((double) goldfinch->emu8k.buffer[c]);
out_r += ((double) goldfinch->emu8k.buffer[c + 1]);
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
emu8k_reset_buffer(&goldfinch->emu8k);
}
static void
sb_get_wavetable_buffer_sb16_awe32(int32_t *buffer, const uint16_t len, void *priv)
{
sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
double bass_treble;
emu8k_update(&sb->emu8k);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
out_l += (((double) sb->emu8k.buffer[c]) * mixer->fm_l);
out_r += (((double) sb->emu8k.buffer[c + 1]) * mixer->fm_r);
out_l *= mixer->master_l;
out_r *= mixer->master_r;
/* This is not exactly how one does bass/treble controls, but the end result is like it.
A better implementation would reduce the CPU usage. */
if (mixer->bass_l != 8) {
bass_treble = sb_bass_treble_4bits[mixer->bass_l];
if (mixer->bass_l > 8)
out_l += (low_iir(4, 0, out_l) * bass_treble);
else
out_l = (out_l *bass_treble + low_cut_iir(4, 0, out_l) * (1.0 - bass_treble));
}
if (mixer->bass_r != 8) {
bass_treble = sb_bass_treble_4bits[mixer->bass_r];
if (mixer->bass_r > 8)
out_r += (low_iir(4, 1, out_r) * bass_treble);
else
out_r = (out_r *bass_treble + low_cut_iir(4, 1, out_r) * (1.0 - bass_treble));
}
if (mixer->treble_l != 8) {
bass_treble = sb_bass_treble_4bits[mixer->treble_l];
if (mixer->treble_l > 8)
out_l += (high_iir(4, 0, out_l) * bass_treble);
else
out_l = (out_l *bass_treble + high_cut_iir(4, 0, out_l) * (1.0 - bass_treble));
}
if (mixer->treble_r != 8) {
bass_treble = sb_bass_treble_4bits[mixer->treble_r];
if (mixer->treble_r > 8)
out_r += (high_iir(4, 1, out_r) * bass_treble);
else
out_r = (out_r *bass_treble + high_cut_iir(4, 1, out_r) * (1.0 - bass_treble));
}
buffer[c] += (int32_t) (out_l * mixer->output_gain_L);
buffer[c + 1] += (int32_t) (out_r * mixer->output_gain_R);
}
emu8k_reset_buffer(&sb->emu8k);
}
void
sb16_awe32_filter_cd_audio(int channel, double *buffer, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
const double cd = channel ? mixer->cd_r : mixer->cd_l /* / 3.0 */;
const double master = channel ? mixer->master_r : mixer->master_l;
const int32_t bass = channel ? mixer->bass_r : mixer->bass_l;
const int32_t treble = channel ? mixer->treble_r : mixer->treble_l;
const double output_gain = (channel ? mixer->output_gain_R : mixer->output_gain_L);
double bass_treble;
double c = (((*buffer) * cd) / 3.0) * master;
/* This is not exactly how one does bass/treble controls, but the end result is like it.
A better implementation would reduce the CPU usage. */
if (bass != 8) {
bass_treble = sb_bass_treble_4bits[bass];
if (bass > 8)
c += (low_iir(2, channel, c) * bass_treble);
else
c = (c * bass_treble + low_cut_iir(2, channel, c) * (1.0 - bass_treble));
}
if (treble != 8) {
bass_treble = sb_bass_treble_4bits[treble];
if (treble > 8)
c += (high_iir(2, channel, c) * bass_treble);
else
c = (c * bass_treble + high_cut_iir(2, channel, c) * (1.0 - bass_treble));
}
*buffer = c * output_gain;
}
void
sb16_awe32_filter_pc_speaker(int channel, double *buffer, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
const double spk = mixer->speaker;
const double master = channel ? mixer->master_r : mixer->master_l;
const int32_t bass = channel ? mixer->bass_r : mixer->bass_l;
const int32_t treble = channel ? mixer->treble_r : mixer->treble_l;
const double output_gain = (channel ? mixer->output_gain_R : mixer->output_gain_L);
double c = (((*buffer) * spk) / 3.0) * master;
double bass_treble;
/* This is not exactly how one does bass/treble controls, but the end result is like it.
A better implementation would reduce the CPU usage. */
if (bass != 8) {
bass_treble = sb_bass_treble_4bits[bass];
if (bass > 8)
c += (low_iir(3, channel, c) * bass_treble);
else
c = (c * bass_treble + low_cut_iir(3, channel, c) * (1.0 - bass_treble));
}
if (treble != 8) {
bass_treble = sb_bass_treble_4bits[treble];
if (treble > 8)
c += (high_iir(3, channel, c) * bass_treble);
else
c = (c * bass_treble + high_cut_iir(3, channel, c) * (1.0 - bass_treble));
}
*buffer = c * output_gain;
}
void
sb16_awe32_filter_midi(int channel, double *buffer, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
const double fm = channel ? mixer->fm_r : mixer->fm_l /* / 3.0 */;
const double master = channel ? mixer->master_r : mixer->master_l;
const int32_t bass = channel ? mixer->bass_r : mixer->bass_l;
const int32_t treble = channel ? mixer->treble_r : mixer->treble_l;
const double output_gain = (channel ? mixer->output_gain_R : mixer->output_gain_L);
double bass_treble;
double c = (((*buffer) * fm) / 3.0) * master;
/* This is not exactly how one does bass/treble controls, but the end result is like it.
A better implementation would reduce the CPU usage. */
if (bass != 8) {
bass_treble = sb_bass_treble_4bits[bass];
if (bass > 8)
c += (low_iir(5, channel, c) * bass_treble);
else
c = (c * bass_treble + low_cut_iir(5, channel, c) * (1.0 - bass_treble));
}
if (treble != 8) {
bass_treble = sb_bass_treble_4bits[treble];
if (treble > 8)
c += (high_iir(5, channel, c) * bass_treble);
else
c = (c * bass_treble + high_cut_iir(5, channel, c) * (1.0 - bass_treble));
}
*buffer = c * output_gain;
}
void ess_dac2_update(void *priv);
void
sb_get_buffer_ess488(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *ess = (sb_t *) priv;
sb_dsp_update(&ess->dsp);
for (int c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
if (ess->dsp.sb_speaker)
out_l = out_r += (low_fir_sb16(1, (double) ess->dsp.buffer[c]) * ess->dsp.es488_voice) / 3.0;
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
ess->dsp.pos = 0;
}
static void
sb_get_music_buffer_ess488(int32_t *buffer, uint16_t len, void *priv)
{
const sb_t *ess = (const sb_t *) priv;
const int32_t *opl_buf = NULL;
opl_buf = ess->opl.update(ess->opl.priv);
for (uint16_t c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
const double out_mono = ((double) opl_buf[c]) * 0.7171630859375;
out_l += out_mono;
out_r += out_mono;
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
ess->opl.reset_buffer(ess->opl.priv);
}
void
sb_get_buffer_ess(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
sb_dsp_update(&ess->dsp);
for (int c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
/* TODO: Implement the stereo switch on the mixer instead of on the dsp? */
if (mixer->output_filter) {
out_l += (low_fir_sb16(0, (double) ess->dsp.buffer[c]) * mixer->voice_l) / 3.0;
out_r += (low_fir_sb16(1, (double) ess->dsp.buffer[c + 1]) * mixer->voice_r) / 3.0;
} else {
out_l += (ess->dsp.buffer[c] * mixer->voice_l) / 3.0;
out_r += (ess->dsp.buffer[c + 1] * mixer->voice_r) / 3.0;
}
/* TODO: recording from the mixer. */
out_l *= mixer->master_l;
out_r *= mixer->master_r;
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1488)
out_r = out_l;
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
ess->dsp.pos = 0;
}
void
sb_get_buffer_ess_dac2(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
ess_dac2_update(ess);
for (int c = 0; c < len * 2; c += 2) {
double out_l = 0.0;
double out_r = 0.0;
if (mixer->output_filter_dac2) {
out_l += (low_fir_ess_dac2(0, (double) ess->ess_dac2_buffer[c]) * mixer->dac2_l) / 3.0;
out_r += (low_fir_ess_dac2(1, (double) ess->ess_dac2_buffer[c + 1]) * mixer->dac2_r) / 3.0;
} else {
out_l += (ess->ess_dac2_buffer[c] * mixer->dac2_l) / 3.0;
out_r += (ess->ess_dac2_buffer[c + 1] * mixer->dac2_r) / 3.0;
}
out_l *= mixer->master_l;
out_r *= mixer->master_r;
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
ess->ess_dac2_pos = 0;
}
void
sb_get_music_buffer_ess(int32_t *buffer, uint16_t len, void *priv)
{
sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
double out_l = 0.0;
double out_r = 0.0;
const int32_t *opl_buf = NULL;
opl_buf = ess->opl.update(ess->opl.priv);
for (uint16_t c = 0; c < len * 2; c += 2) {
out_l = 0.0;
out_r = 0.0;
out_l = (((double) opl_buf[c]) * mixer->fm_l) * 0.7171630859375;
out_r = (((double) opl_buf[c + 1]) * mixer->fm_r) * 0.7171630859375;
if (ess->opl_mix && ess->opl_mixer)
ess->opl_mix(ess->opl_mixer, &out_l, &out_r);
/* TODO: recording from the mixer. */
out_l *= mixer->master_l;
out_r *= mixer->master_r;
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1488)
out_r = out_l;
buffer[c] += (int32_t) out_l;
buffer[c + 1] += (int32_t) out_r;
}
ess->opl.reset_buffer(ess->opl.priv);
}
void
ess_filter_cd_audio(int channel, double *buffer, void *priv)
{
const sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
const double cd = channel ? mixer->cd_r : mixer->cd_l;
const double master = channel ? mixer->master_r : mixer->master_l;
const double c = ((*buffer * cd) / 3.0) * master;
/* TODO: recording from the mixer. */
*buffer = c;
}
void
ess_filter_pc_speaker(int channel, double *buffer, void *priv)
{
const sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
const double spk = mixer->speaker;
const double master = channel ? mixer->master_r : mixer->master_l;
const double c = (((*buffer) * spk) / 3.0) * master;
*buffer = c;
}
void
ess_filter_midi(int channel, double *buffer, void *priv)
{
const sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
const double fm = channel ? mixer->fm_r : mixer->fm_l;
const double master = channel ? mixer->master_r : mixer->master_l;
const double c = ((*buffer * fm) / 3.0) * master;
/* TODO: recording from the mixer. */
*buffer = c;
}
void
sb_ct1335_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *sb = (sb_t *) priv;
sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
if (!(addr & 1)) {
mixer->index = val;
mixer->regs[0x01] = val;
} else {
if (mixer->index == 0) {
/* Reset */
mixer->regs[0x02] = mixer->regs[0x06] = 0x08;
mixer->regs[0x08] = 0x00;
/* Changed default from -46dB to 0dB*/
mixer->regs[0x0a] = 0x06;
} else {
mixer->regs[mixer->index] = val;
switch (mixer->index) {
case 0x00:
case 0x02:
case 0x06:
case 0x08:
case 0x0a:
break;
default:
sb_log("sb_ct1335: Unknown register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
break;
}
}
mixer->master = sb_att_4dbstep_3bits[(mixer->regs[0x02] >> 1) & 0x7] / 32768.0;
mixer->fm = sb_att_4dbstep_3bits[(mixer->regs[0x06] >> 1) & 0x7] / 32768.0;
mixer->cd = sb_att_4dbstep_3bits[(mixer->regs[0x08] >> 1) & 0x7] / 32768.0;
mixer->voice = sb_att_7dbstep_2bits[(mixer->regs[0x0a] >> 1) & 0x3] / 32768.0;
}
}
uint8_t
sb_ct1335_mixer_read(uint16_t addr, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
if (!(addr & 1))
return mixer->index;
switch (mixer->index) {
case 0x00:
case 0x02:
case 0x06:
case 0x08:
case 0x0A:
return mixer->regs[mixer->index];
default:
sb_log("sb_ct1335: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
break;
}
return 0xff;
}
void
sb_ct1335_mixer_reset(sb_t *sb)
{
sb_ct1335_mixer_write(0x254, 0, sb);
sb_ct1335_mixer_write(0x255, 0, sb);
}
void
sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *sb = (sb_t *) priv;
sb_ct1345_mixer_t *mixer = (sb == NULL) ? NULL : &sb->mixer_sbpro;
if (mixer == NULL)
return;
if (!(addr & 1)) {
mixer->index = val;
mixer->regs[0x01] = val;
} else {
if (mixer->index == 0) {
/* Reset */
mixer->regs[0x0a] = mixer->regs[0x0c] = 0x00;
mixer->regs[0x0e] = 0x00;
/* Changed default from -11dB to 0dB */
mixer->regs[0x04] = mixer->regs[0x22] = 0xee;
mixer->regs[0x26] = mixer->regs[0x28] = 0xee;
mixer->regs[0x2e] = 0x00;
sb_dsp_set_stereo(&sb->dsp, mixer->regs[0x0e] & 2);
} else if (sb->dsp.sb_subtype == SB_SUBTYPE_CLONE_AZTPR16_0X09) {
mixer->regs[mixer->index] = val;
sb_log("sb_ct1345: Register WRITE, AZTPR16: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
aztpr16_update_mixer(sb->dsp.parent);
switch (mixer->index) {
/* Compatibility: chain registers 0x02 and 0x22 as well as 0x06 and 0x26 */
case 0x02:
case 0x06:
case 0x08:
mixer->regs[mixer->index + 0x20] = ((val & 0xe) << 4) | (val & 0xe);
break;
case 0x22:
case 0x26:
case 0x28:
mixer->regs[mixer->index - 0x20] = (val & 0xe);
break;
/* More compatibility:
SoundBlaster Pro selects register 020h for 030h, 022h for 032h,
026h for 036h, and 028h for 038h. */
case 0x30:
case 0x32:
case 0x36:
case 0x38:
mixer->regs[mixer->index - 0x10] = (val & 0xee);
break;
case 0x00:
case 0x04:
case 0x0a:
case 0x0c:
case 0x0e:
case 0x2e:
/* Aztech AZTPR16 mixer */
case 0x84:
case 0x86:
case 0x88:
case 0x8a:
case 0x8c:
case 0x8e:
case 0xa0:
case 0xa2:
case 0xa4:
case 0xa6:
case 0xa8:
case 0xaa:
case 0xac:
case 0xae:
case 0xc2:
case 0xc4:
case 0xc6:
case 0xc8:
case 0xca:
case 0xcc:
case 0xce:
case 0xe0:
case 0xe2:
case 0xe4:
case 0xe6:
case 0xe8:
break;
default:
sb_log("sb_ct1345: Unknown register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
break;
}
} else {
mixer->regs[mixer->index] = val;
switch (mixer->index) {
/* Compatibility: chain registers 0x02 and 0x22 as well as 0x06 and 0x26 */
case 0x02:
case 0x06:
case 0x08:
mixer->regs[mixer->index + 0x20] = ((val & 0xe) << 4) | (val & 0xe);
break;
case 0x22:
case 0x26:
case 0x28:
mixer->regs[mixer->index - 0x20] = (val & 0xe);
break;
/* More compatibility:
SoundBlaster Pro selects register 020h for 030h, 022h for 032h,
026h for 036h, and 028h for 038h. */
case 0x30:
case 0x32:
case 0x36:
case 0x38:
mixer->regs[mixer->index - 0x10] = (val & 0xee);
break;
case 0x00:
case 0x04:
case 0x0a:
case 0x0c:
case 0x0e:
case 0x2e:
break;
default:
sb_log("sb_ct1345: Unknown register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
break;
}
}
mixer->voice_l = sb_att_4dbstep_3bits[(mixer->regs[0x04] >> 5) & 0x7] / 32768.0;
mixer->voice_r = sb_att_4dbstep_3bits[(mixer->regs[0x04] >> 1) & 0x7] / 32768.0;
mixer->master_l = sb_att_4dbstep_3bits[(mixer->regs[0x22] >> 5) & 0x7] / 32768.0;
mixer->master_r = sb_att_4dbstep_3bits[(mixer->regs[0x22] >> 1) & 0x7] / 32768.0;
mixer->fm_l = sb_att_4dbstep_3bits[(mixer->regs[0x26] >> 5) & 0x7] / 32768.0;
mixer->fm_r = sb_att_4dbstep_3bits[(mixer->regs[0x26] >> 1) & 0x7] / 32768.0;
mixer->cd_l = sb_att_4dbstep_3bits[(mixer->regs[0x28] >> 5) & 0x7] / 32768.0;
mixer->cd_r = sb_att_4dbstep_3bits[(mixer->regs[0x28] >> 1) & 0x7] / 32768.0;
mixer->line_l = sb_att_4dbstep_3bits[(mixer->regs[0x2e] >> 5) & 0x7] / 32768.0;
mixer->line_r = sb_att_4dbstep_3bits[(mixer->regs[0x2e] >> 1) & 0x7] / 32768.0;
if (sb->dsp.sb_subtype == SB_SUBTYPE_CLONE_AZTPR16_0X09) {
mixer->master_l = sb_att_2dbstep_5bits[((mixer->regs[0x84] >> 1) & 0x1f)] / 32768.0;
mixer->master_r = sb_att_2dbstep_5bits[((mixer->regs[0x86] >> 1) & 0x1f)] / 32768.0;
}
if (sb->dsp.sb_subtype == SB_SUBTYPE_CLONE_AZT1605_0X0C)
azt1605_update_mixer(sb->dsp.parent);
mixer->mic = sb_att_7dbstep_2bits[(mixer->regs[0x0a] >> 1) & 0x3] / 32768.0;
switch (sb->mixer_quirks) {
case QUIRK_NOFILTER:
mixer->output_filter = mixer->input_filter = 0;
break;
case QUIRK_FILTERND:
mixer->output_filter = mixer->input_filter = 1;
break;
default:
mixer->output_filter = !(mixer->regs[0xe] & 0x20);
mixer->input_filter = !(mixer->regs[0xc] & 0x20);
break;
}
mixer->in_filter_freq = ((mixer->regs[0xc] & 0x8) == 0) ? 3200 : 8800;
mixer->stereo = mixer->regs[0xe] & 2;
if (mixer->index == 0xe)
sb_dsp_set_stereo(&sb->dsp, val & 2);
switch (mixer->regs[0xc] & 6) {
case 2:
mixer->input_selector = INPUT_CD_L | INPUT_CD_R;
break;
case 6:
mixer->input_selector = INPUT_LINE_L | INPUT_LINE_R;
break;
default:
mixer->input_selector = INPUT_MIC;
break;
}
/* TODO: pcspeaker volume? Or is it not worth? */
}
}
uint8_t
sb_ct1345_mixer_read(uint16_t addr, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
if (!(addr & 1))
return mixer->index;
switch (mixer->index) {
case 0x00:
case 0x04:
case 0x0a:
case 0x0c:
case 0x0e:
case 0x22:
case 0x26:
case 0x28:
case 0x2e:
case 0x02:
case 0x06:
case 0x30:
case 0x32:
case 0x36:
case 0x38:
return mixer->regs[mixer->index];
case 0x62:
/* Aztech AZT2320 */
if (sb->dsp.sb_subtype == SB_SUBTYPE_CLONE_AZT2320_0X13)
return 0x13;
break;
/* Aztech AZTPR16 mixer */
case 0x84:
case 0x86:
case 0x88:
case 0x8a:
case 0x8c:
case 0x8e:
case 0xa0:
case 0xa2:
case 0xa4:
case 0xa6:
case 0xa8:
case 0xaa:
case 0xac:
case 0xae:
case 0xc2:
case 0xc4:
case 0xc6:
case 0xc8:
case 0xca:
case 0xcc:
case 0xce:
case 0xe0:
case 0xe2:
case 0xe4:
case 0xe6:
case 0xe8:
if (sb->dsp.sb_subtype == SB_SUBTYPE_CLONE_AZTPR16_0X09)
return mixer->regs[mixer->index];
default:
sb_log("sb_ct1345: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
break;
}
return 0xff;
}
void
sb_ct1345_mixer_reset(sb_t *sb)
{
sb_ct1345_mixer_write(4, 0, sb);
sb_ct1345_mixer_write(5, 0, sb);
}
void
sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *sb = (sb_t *) priv;
sb_ct1745_mixer_t *mixer = (sb == NULL) ? NULL : &sb->mixer_sb16;
if (mixer == NULL)
return;
if (!(addr & 1))
mixer->index = val;
else {
/* DESCRIPTION:
Contains previously selected register value. Mixer Data Register value.
NOTES:
SoundBlaster 16 sets bit 7 if previous mixer index invalid.
Status bytes initially 080h on startup for all but level bytes (SB16). */
sb_log("CT1745: [W] %02X = %02X\n", mixer->index, val);
if (mixer->index == 0) {
/* Reset: Changed defaults from -14dB to 0dB */
mixer->regs[0x30] = mixer->regs[0x31] = 0xf8;
mixer->regs[0x32] = mixer->regs[0x33] = 0xf8;
mixer->regs[0x34] = mixer->regs[0x35] = 0xf8;
mixer->regs[0x36] = mixer->regs[0x37] = 0xf8;
mixer->regs[0x38] = mixer->regs[0x39] = 0x00;
mixer->regs[0x3a] = 0x00;
/* Speaker control - it appears to be in steps of 64. */
mixer->regs[0x3b] = 0x80;
mixer->regs[0x3c] = (OUTPUT_MIC | OUTPUT_CD_R | OUTPUT_CD_L | OUTPUT_LINE_R | OUTPUT_LINE_L);
mixer->regs[0x3d] = (INPUT_MIC | INPUT_CD_L | INPUT_LINE_L | INPUT_MIDI_L);
mixer->regs[0x3e] = (INPUT_MIC | INPUT_CD_R | INPUT_LINE_R | INPUT_MIDI_R);
mixer->regs[0x3f] = mixer->regs[0x40] = 0x00;
mixer->regs[0x41] = mixer->regs[0x42] = 0x00;
mixer->regs[0x44] = mixer->regs[0x45] = 0x80;
mixer->regs[0x46] = mixer->regs[0x47] = 0x80;
/* 0x43 = Mic AGC (Automatic Gain Control?) according to Linux's sb.h.
NSC LM4560 datasheet: Bit 0: 1 = Enable, 0 = Disable;
Another source says this: Bit 0: 0 = AGC on (default), 1 = Fixed gain of 20 dB. */
mixer->regs[0x43] = 0x00;
mixer->regs[0x49] = mixer->regs[0x4a] = 0x80;
mixer->regs[0x83] = 0xff;
sb->dsp.sb_irqm8 = 0;
sb->dsp.sb_irqm16 = 0;
sb->dsp.sb_irqm401 = 0;
mixer->regs[0xfd] = 0x10;
mixer->regs[0xfe] = 0x06;
mixer->regs[0xff] = sb->dsp.sb_16_dma_supported ? 0x05 : 0x03;
sb_dsp_setdma16_enabled(&sb->dsp, 0x01);
sb_dsp_setdma16_translate(&sb->dsp, mixer->regs[0xff] & 0x02);
} else
mixer->regs[mixer->index] = val;
switch (mixer->index) {
/* SB1/2 compatibility? */
case 0x02:
mixer->regs[0x30] = ((mixer->regs[0x02] & 0xf) << 4) | 0x8;
mixer->regs[0x31] = ((mixer->regs[0x02] & 0xf) << 4) | 0x8;
break;
case 0x06:
mixer->regs[0x34] = ((mixer->regs[0x06] & 0xf) << 4) | 0x8;
mixer->regs[0x35] = ((mixer->regs[0x06] & 0xf) << 4) | 0x8;
break;
case 0x08:
mixer->regs[0x36] = ((mixer->regs[0x08] & 0xf) << 4) | 0x8;
mixer->regs[0x37] = ((mixer->regs[0x08] & 0xf) << 4) | 0x8;
break;
/* SBPro compatibility. Copy values to sb16 registers. */
case 0x22:
mixer->regs[0x30] = (mixer->regs[0x22] & 0xf0) | 0x8;
mixer->regs[0x31] = ((mixer->regs[0x22] & 0xf) << 4) | 0x8;
break;
case 0x04:
mixer->regs[0x32] = (mixer->regs[0x04] & 0xf0) | 0x8;
mixer->regs[0x33] = ((mixer->regs[0x04] & 0xf) << 4) | 0x8;
break;
case 0x26:
mixer->regs[0x34] = (mixer->regs[0x26] & 0xf0) | 0x8;
mixer->regs[0x35] = ((mixer->regs[0x26] & 0xf) << 4) | 0x8;
break;
case 0x28:
mixer->regs[0x36] = (mixer->regs[0x28] & 0xf0) | 0x8;
mixer->regs[0x37] = ((mixer->regs[0x28] & 0xf) << 4) | 0x8;
break;
case 0x0A:
mixer->regs[0x3a] = (mixer->regs[0x0a] << 5) | 0x18;
break;
case 0x2e:
mixer->regs[0x38] = (mixer->regs[0x2e] & 0xf0) | 0x8;
mixer->regs[0x39] = ((mixer->regs[0x2e] & 0xf) << 4) | 0x8;
break;
/* (DSP 4.xx feature):
The Interrupt Setup register, addressed as register 80h on the Mixer register map,
is used to configure or determine the Interrupt request line.
The DMA setup register, addressed as register 81h on the Mixer register map, is
used to configure or determine the DMA channels.
Note: Registers 80h and 81h are Read-only for PnP boards. */
case 0x80:
if (!sb->pnp) {
if (val & 0x01)
sb_dsp_setirq(&sb->dsp, 2);
if (val & 0x02)
sb_dsp_setirq(&sb->dsp, 5);
if (val & 0x04)
sb_dsp_setirq(&sb->dsp, 7);
if (val & 0x08)
sb_dsp_setirq(&sb->dsp, 10);
}
break;
case 0x81:
/* The documentation is confusing. sounds as if multple dma8 channels could
be set. */
if (!sb->pnp) {
if (val & 0x01)
sb_dsp_setdma8(&sb->dsp, 0);
else if (val & 0x02)
sb_dsp_setdma8(&sb->dsp, 1);
else if (val & 0x08)
sb_dsp_setdma8(&sb->dsp, 3);
sb_dsp_setdma16(&sb->dsp, 4);
if (val & 0x20)
sb_dsp_setdma16(&sb->dsp, 5);
else if (val & 0x40)
sb_dsp_setdma16(&sb->dsp, 6);
else if (val & 0x80)
sb_dsp_setdma16(&sb->dsp, 7);
}
break;
case 0x83:
/* Interrupt mask. */
sb_update_mask(&sb->dsp, !(val & 0x01), !(val & 0x02), !(val & 0x04));
break;
case 0x84:
/* MPU Control register, per the Linux source code. */
/* Bits 2-1: MPU-401 address:
0, 0 = 330h;
0, 1 = Disabled;
1, 0 = 300h;
1, 1 = ???? (Reserved?)
Bit 0: Gameport address:
0, 0 = 200-207h;
0, 1 = Disabled
*/
if (!sb->pnp) {
if (sb->mpu != NULL) {
if ((val & 0x06) == 0x00)
mpu401_change_addr(sb->mpu, 0x330);
else if ((val & 0x06) == 0x04)
mpu401_change_addr(sb->mpu, 0x300);
else if ((val & 0x06) == 0x02)
mpu401_change_addr(sb->mpu, 0);
}
sb->gameport_addr = 0;
if (sb->gameport != NULL) {
gameport_remap(sb->gameport, 0);
if (!(val & 0x01)) {
sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, 0x200);
}
}
}
break;
case 0xff:
if ((sb->dsp.sb_type > SBAWE32_DSP_412) && !sb->dsp.sb_16_dma_supported) {
/*
Bit 5: High DMA channel enabled (0 = yes, 1 = no);
Bit 2: ????;
Bit 1: ???? (16-bit to 8-bit translation?);
Bit 0: ????
Seen values: 20, 05, 04, 03
*/
sb_dsp_setdma16_enabled(&sb->dsp, !(val & 0x20));
#ifdef TOGGLABLE_TRANSLATION
sb_dsp_setdma16_translate(&sb->dsp, val & 0x02);
#endif
}
break;
default:
break;
}
mixer->output_selector = mixer->regs[0x3c];
mixer->input_selector_left = mixer->regs[0x3d];
mixer->input_selector_right = mixer->regs[0x3e];
mixer->master_l = sb_att_2dbstep_5bits[mixer->regs[0x30] >> 3] / 32768.0;
mixer->master_r = sb_att_2dbstep_5bits[mixer->regs[0x31] >> 3] / 32768.0;
mixer->voice_l = sb_att_2dbstep_5bits[mixer->regs[0x32] >> 3] / 32768.0;
mixer->voice_r = sb_att_2dbstep_5bits[mixer->regs[0x33] >> 3] / 32768.0;
mixer->fm_l = sb_att_2dbstep_5bits[mixer->regs[0x34] >> 3] / 32768.0;
mixer->fm_r = sb_att_2dbstep_5bits[mixer->regs[0x35] >> 3] / 32768.0;
mixer->cd_l = (mixer->output_selector & OUTPUT_CD_L) ? (sb_att_2dbstep_5bits[mixer->regs[0x36] >> 3] / 32768.0) : 0.0;
mixer->cd_r = (mixer->output_selector & OUTPUT_CD_R) ? (sb_att_2dbstep_5bits[mixer->regs[0x37] >> 3] / 32768.0) : 0.0;
mixer->line_l = (mixer->output_selector & OUTPUT_LINE_L) ? (sb_att_2dbstep_5bits[mixer->regs[0x38] >> 3] / 32768.0) : 0.0;
mixer->line_r = (mixer->output_selector & OUTPUT_LINE_R) ? (sb_att_2dbstep_5bits[mixer->regs[0x39] >> 3] / 32768.0) : 0.0;
mixer->mic = sb_att_2dbstep_5bits[mixer->regs[0x3a] >> 3] / 32768.0;
mixer->speaker = sb_att_7dbstep_2bits[(mixer->regs[0x3b] >> 6) & 0x3] / 32768.0;
mixer->input_gain_L = (mixer->regs[0x3f] >> 6);
mixer->input_gain_R = (mixer->regs[0x40] >> 6);
mixer->output_gain_L = (double) (1 << (mixer->regs[0x41] >> 6));
mixer->output_gain_R = (double) (1 << (mixer->regs[0x42] >> 6));
mixer->bass_l = mixer->regs[0x46] >> 4;
mixer->bass_r = mixer->regs[0x47] >> 4;
mixer->treble_l = mixer->regs[0x44] >> 4;
mixer->treble_r = mixer->regs[0x45] >> 4;
/* TODO: PC Speaker volume, with "output_selector" check? or better not? */
sb_log("sb_ct1745: Received register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
}
}
uint8_t
sb_ct1745_mixer_read(uint16_t addr, void *priv)
{
const sb_t *sb = (sb_t *) priv;
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
uint8_t ret = 0xff;
sb_log("sb_ct1745: received register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
if (!(addr & 1))
ret = 0xff /*mixer->index*/;
else if ((mixer->index >= 0x30) && (mixer->index <= 0x47))
ret = mixer->regs[mixer->index];
else {
switch (mixer->index) {
case 0x00:
ret = mixer->regs[mixer->index];
break;
/*SB Pro compatibility*/
case 0x04:
ret = ((mixer->regs[0x33] >> 4) & 0x0f) | (mixer->regs[0x32] & 0xf0);
break;
case 0x0a:
ret = (mixer->regs[0x3a] >> 5);
break;
case 0x02:
ret = ((mixer->regs[0x30] >> 4) & 0x0f);
break;
case 0x06:
ret = ((mixer->regs[0x34] >> 4) & 0x0f);
break;
case 0x08:
ret = ((mixer->regs[0x36] >> 4) & 0x0f);
break;
case 0x0e:
ret = 0x02;
break;
case 0x22:
ret = ((mixer->regs[0x31] >> 4) & 0x0f) | (mixer->regs[0x30] & 0xf0);
break;
case 0x26:
ret = ((mixer->regs[0x35] >> 4) & 0x0f) | (mixer->regs[0x34] & 0xf0);
break;
case 0x28:
ret = ((mixer->regs[0x37] >> 4) & 0x0f) | (mixer->regs[0x36] & 0xf0);
break;
case 0x2e:
ret = ((mixer->regs[0x39] >> 4) & 0x0f) | (mixer->regs[0x38] & 0xf0);
break;
case 0x48:
/* Undocumented. The Creative Windows Mixer calls this after calling 3C (input selector),
even when writing.
Also, the version I have (5.17), does not use the MIDI.L/R input selectors, it uses
the volume to mute (Affecting the output, obviously). */
ret = mixer->regs[mixer->index];
break;
case 0x80:
/* TODO: Unaffected by mixer reset or soft reboot.
Enabling multiple bits enables multiple IRQs. */
switch (sb->dsp.sb_irqnum) {
case 2:
ret = 1;
break;
case 5:
ret = 2;
break;
case 7:
ret = 4;
break;
case 10:
ret = 8;
break;
default:
break;
}
break;
case 0x81:
/* TODO: Unaffected by mixer reset or soft reboot.
Enabling multiple 8 or 16-bit DMA bits enables multiple DMA channels.
Disabling all 8-bit DMA channel bits disables 8-bit DMA requests,
including translated 16-bit DMA requests.
Disabling all 16-bit DMA channel bits enables translation of 16-bit DMA
requests to 8-bit ones, using the selected 8-bit DMA channel. */
ret = 0;
switch (sb->dsp.sb_8_dmanum) {
case 0:
ret |= 1;
break;
case 1:
ret |= 2;
break;
case 3:
ret |= 8;
break;
default:
break;
}
switch (sb->dsp.sb_16_dmanum) {
default:
break;
case 5:
ret |= 0x20;
break;
case 6:
ret |= 0x40;
break;
case 7:
ret |= 0x80;
break;
}
break;
case 0x82:
; /* Empty statement to make compilers happy about the following variable declaration. */
/* The Interrupt status register, addressed as register 82h on the Mixer register map,
is used by the ISR to determine whether the interrupt is meant for it or for some
other ISR, in which case it should chain to the previous routine. */
/* 0 = none, 1 = digital 8bit or SBMIDI, 2 = digital 16bit, 4 = MPU-401 */
/* 0x02000 DSP v4.04, 0x4000 DSP v4.05, 0x8000 DSP v4.12.
I haven't seen this making any difference, but I'm keeping it for now. */
/* If QEMU is any indication, then the values are actually 0x20, 0x40, and 0x80. */
/* http://the.earth.li/~tfm/oldpage/sb_mixer.html - 0x10, 0x20, 0x80. */
uint8_t temp;
temp = ((sb->dsp.sb_irq8) ? 1 : 0) | ((sb->dsp.sb_irq16) ? 2 : 0) |
((sb->dsp.sb_irq401) ? 4 : 0);
if (sb->dsp.sb_type >= SB16_DSP_411)
ret = temp | 0x80;
else if (sb->dsp.sb_type == SB16_DSP_405)
ret = temp | 0x20;
else if (sb->dsp.sb_type == SB16_DSP_404)
ret = temp | 0x10;
else
ret = temp | 0x40;
break;
case 0x83:
/* Interrupt mask. */
ret = mixer->regs[mixer->index];
break;
case 0x84:
/* MPU Control. */
if (sb->mpu == NULL)
ret = 0x02;
else {
if (sb->mpu->addr == 0x330)
ret = 0x00;
else if (sb->mpu->addr == 0x300)
ret = 0x04;
else if (sb->mpu->addr == 0)
ret = 0x02;
else
ret = 0x06; /* Should never happen. */
}
if (!sb->gameport_addr)
ret |= 0x01;
break;
case 0x49: /* Undocumented register used by some Creative drivers. */
case 0x4a: /* Undocumented register used by some Creative drivers. */
case 0x8c: /* Undocumented register used by some Creative drivers. */
case 0x8e: /* Undocumented register used by some Creative drivers. */
case 0x90: /* 3D Enhancement switch. */
case 0xfd: /* Undocumented register used by some Creative drivers. */
case 0xfe: /* Undocumented register used by some Creative drivers. */
ret = mixer->regs[mixer->index];
break;
case 0xff: /* Undocumented register used by some Creative drivers.
This and the upper bits of 0x82 seem to affect the
playback volume:
- Register FF = FF: Volume playback normal.
- Register FF = Not FF: Volume playback low unless
bit 6 of 82h is set. */
if (sb->dsp.sb_type > SBAWE32_DSP_412)
ret = mixer->regs[mixer->index];
break;
default:
sb_log("sb_ct1745: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
break;
}
sb_log("CT1745: [R] %02X = %02X\n", mixer->index, ret);
}
sb_log("CT1745: read REG%02X: %02X\n", mixer->index, ret);
return ret;
}
void
sb_ct1745_mixer_reset(sb_t *sb)
{
if (sb != NULL) {
sb_ct1745_mixer_write(4, 0, sb);
sb_ct1745_mixer_write(5, 0, sb);
}
}
static void
ess_base_write(uint16_t addr, UNUSED(uint8_t val), void *priv)
{
sb_t *ess = (sb_t *) priv;
switch (addr & 0x000f) {
default:
break;
case 0x0002:
case 0x0003:
case 0x0006:
case 0x000c:
ess->dsp.activity &= 0xdf;
break;
case 0x0008:
case 0x0009:
ess->dsp.activity &= 0x7f;
break;
}
}
static uint8_t
ess_base_read(uint16_t addr, void *priv)
{
sb_t *ess = (sb_t *) priv;
switch (addr & 0x000f) {
default:
break;
case 0x0002:
case 0x0003:
case 0x0004: /* Undocumented but tested by the LBA 2 ES688 driver. */
case 0x000a:
ess->dsp.activity &= 0xdf;
break;
case 0x0008:
case 0x0009:
ess->dsp.activity &= 0x7f;
break;
case 0x000c:
case 0x000e:
ess->dsp.activity &= 0xbf;
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
if (!ess->ess_dac2_irq) /* Shared IRQ mode */
picintc(1 << ess->dsp.sb_irqnum);
else
picintc(1 << ess->ess_dac2_irq);
}
break;
}
sb_log("ess_base_read(%04X): %04X, activity now: %02X\n", addr, addr & 0x000f, ess->dsp.activity);
return 0xff;
}
static void
ess_fm_midi_write(UNUSED(uint16_t addr), UNUSED(uint8_t val), void *priv)
{
sb_t *ess = (sb_t *) priv;
ess->dsp.activity &= 0x7f;
}
static uint8_t
ess_fm_midi_read(UNUSED(uint16_t addr), void *priv)
{
sb_t *ess = (sb_t *) priv;
ess->dsp.activity &= 0x7f;
return 0xff;
}
void ess_rsk_reset(void *priv);
static uint8_t ess_rsk_read(uint16_t addr, void *priv);
void
ess_dac2_startdma(void *priv)
{
sb_t *ess = (sb_t *) priv;
sb_log("Starting ESS DAC2 DMA, channel = %i, rate = %i\n", ess->ess_dac2_dma, ess->ess_dac2_freq);
if ((ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1868) || ((ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869) && !(ess->mixer_ess.regs[0x71] & 0x02))) {
/* OS/2 Warp driver does not set the samplerate on DAC2 in full-duplex mode
and per the ES1868 datasheet DAC2 uses the DAC1 sample rate set in A1h/A2h in this mode */
/* ES1869 supports slaving the DAC2 sample rate to DAC1's rate as a configurable mode */
if ((ess->ess_dac2_latcho == 0) || ((ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869) && !(ess->mixer_ess.regs[0x71] & 0x02)))
ess->ess_dac2_latcho = ess->dsp.sblatcho;
}
ess->ess_dac2_enable = 1;
ess->ess_dac2_suspend = 0;
ess->ess_dac2_counter = ess->ess_dac2_autolen;
ess->ess_dac2_dmaff = 0;
ess->dsp.espcm_sample_idx = 0;
if (!timer_is_enabled(&ess->ess_dac2_timer))
timer_set_delay_u64(&ess->ess_dac2_timer, (uint64_t) ess->ess_dac2_latcho);
}
void
ess_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *ess = (sb_t *) priv;
ess_mixer_t *mixer = (ess == NULL) ? NULL : &ess->mixer_ess;
sb_log("[%04X:%08X] [W] %04X = %02X\n", CS, cpu_state.pc, addr, val);
if (mixer == NULL)
return;
if (!(addr & 1)) {
mixer->index = val;
mixer->regs[0x01] = val;
ess->es186x_id_state = 0; /* Reset ES186x ID readout */
} else {
if (mixer->index == 0) {
/* Reset */
mixer->regs[0x0a] = mixer->regs[0x0c] = 0x00;
mixer->regs[0x0e] = 0x00;
mixer->regs[0x04] = mixer->regs[0x22] = 0x88;
mixer->regs[0x26] = 0x88;
mixer->regs[0x28] = mixer->regs[0x2e] = 0x00;
/* Initialize ESS regs */
mixer->regs[0x1a] = 0x00;
mixer->regs[0x14] = mixer->regs[0x32] = 0x88;
mixer->regs[0x36] = 0x88;
mixer->regs[0x38] = mixer->regs[0x3a] = 0x00;
mixer->regs[0x3c] = 0x05;
mixer->regs[0x3e] = 0x00;
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1868)
mixer->regs[0x64] = 0x20;
else if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869)
mixer->regs[0x64] = 0x00;
else
mixer->regs[0x64] = 0x08;
/* Initialize ES1788+ Master Volume */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788)
mixer->regs[0x60] = mixer->regs[0x62] = 0x3f;
sb_dsp_set_stereo(&ess->dsp, mixer->regs[0x0e] & 2);
} else {
mixer->regs[mixer->index] = val;
switch (mixer->index) {
/* Compatibility: chain registers 0x02 and 0x22 as well as 0x06 and 0x26 */
case 0x02:
case 0x06:
case 0x08:
mixer->regs[mixer->index + 0x20] = ((val & 0xe) << 4) | (val & 0xe);
break;
case 0x0A:
{
uint8_t mic_vol_2bit = (mixer->regs[0x0a] >> 1) & 0x3;
mixer->mic_l = mixer->mic_r = sb_att_7dbstep_2bits[mic_vol_2bit] / 32767.0;
mixer->regs[0x1A] = mic_vol_2bit | (mic_vol_2bit << 2) | (mic_vol_2bit << 4) | (mic_vol_2bit << 6);
break;
}
case 0x0C:
switch (mixer->regs[0x0C] & 6) {
case 2:
mixer->input_selector = INPUT_CD_L | INPUT_CD_R;
break;
case 6:
mixer->input_selector = INPUT_LINE_L | INPUT_LINE_R;
break;
default:
mixer->input_selector = INPUT_MIC;
break;
}
/* Filter is always enabled on ES688 and later, per the datasheets the filter control bits have no effect */
break;
case 0x0E:
/* Filter is always enabled on ES688 and later, per the datasheets the filter control bit has no effect */
mixer->stereo = mixer->regs[0xE] & 2;
sb_dsp_set_stereo(&ess->dsp, val & 2);
break;
case 0x14:
mixer->regs[0x4] = val & 0xee;
break;
case 0x1A:
mixer->mic_l = sb_att_1p4dbstep_4bits[(mixer->regs[0x1A] >> 4) & 0xF] / 32767.0;
mixer->mic_r = sb_att_1p4dbstep_4bits[mixer->regs[0x1A] & 0xF] / 32767.0;
break;
case 0x1C:
mixer->regs[mixer->index] = val & 0x2f;
if ((mixer->regs[0x1C] & 0x07) == 0x07) {
mixer->input_selector = INPUT_MIXER_L | INPUT_MIXER_R;
} else if ((mixer->regs[0x1C] & 0x07) == 0x06) {
mixer->input_selector = INPUT_LINE_L | INPUT_LINE_R;
} else if ((mixer->regs[0x1C] & 0x06) == 0x02) {
mixer->input_selector = INPUT_CD_L | INPUT_CD_R;
} else if ((mixer->regs[0x1C] & 0x02) == 0) {
mixer->input_selector = INPUT_MIC;
} else if ((mixer->regs[0x1C] & 0x07) == 0x04) {
mixer->input_selector = INPUT_MIC;
}
break;
case 0x22:
case 0x26:
case 0x28:
case 0x2E:
mixer->regs[mixer->index - 0x20] = (val & 0xe);
mixer->regs[mixer->index + 0x10] = val;
if ((mixer->index == 0x22) && (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788) && !(mixer->regs[0x64] & 0x01)) {
/* ES1788+ SBPro mixer emulation write translation */
mixer->regs[0x60] = ess_4bit_xlat[(val >> 4) & 0x0f];
mixer->regs[0x62] = ess_4bit_xlat[val & 0x0f];
}
break;
/* More compatibility:
SoundBlaster Pro selects register 020h for 030h, 022h for 032h,
026h for 036h, and 028h for 038h. */
case 0x30:
case 0x32:
case 0x36:
case 0x38:
case 0x3e:
mixer->regs[mixer->index - 0x10] = (val & 0xee);
if ((mixer->index == 0x32) && (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788) && !(mixer->regs[0x64] & 0x01)) {
/* ES1788+ ESS 4-bit mixer emulation write translation */
mixer->regs[0x60] = ess_4bit_xlat[(val >> 4) & 0x0f];
mixer->regs[0x62] = ess_4bit_xlat[val & 0x0f];
}
break;
case 0x00:
case 0x04:
case 0x3a:
case 0x3c:
break;
case 0x60:
case 0x62:
mixer->regs[mixer->index] = (val & 0x7f);
break;
case 0x64:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1887) /* ES1887 */
mixer->regs[mixer->index] = (mixer->regs[mixer->index]);
else if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788)
/* ES1788, ES1888 based on datasheet */
mixer->regs[mixer->index] = (mixer->regs[mixer->index]) | 0x20;
break;
case 0x40:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1868)
break;
else if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1688) {
if (((ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788) || ess->es1688_rsk_enable) && (val & 0x04)) {
mixer->regs[0x40] = val & 0xfb;
sb_log("ESS Read-Sequence-Key reset!\n");
ess_rsk_reset(ess);
break;
}
uint16_t mpu401_base_addr = 0x300 | ((mixer->regs[0x40] << 1) & 0x30);
sb_log("mpu401_base_addr = %04X\n", mpu401_base_addr);
io_removehandler(ess->midi_addr, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
if (ess->gameport != NULL)
gameport_remap(ess->gameport, !(mixer->regs[0x40] & 0x2) ? 0x00 : 0x200);
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788) {
/* Not on ES1688. */
io_removehandler(ess->opl_pnp_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
if ((mixer->regs[0x40] & 0x1) != 0) {
io_sethandler(ess->opl_pnp_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
}
}
if (ess->mpu != NULL)
switch ((mixer->regs[0x40] >> 5) & 0x7) {
default:
break;
case 0:
mpu401_base_addr = 0x0000;
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, -1);
break;
case 1:
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, -1);
break;
case 2:
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, ess->dsp.sb_irqnum);
break;
case 3:
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, 11);
break;
case 4:
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, 9);
break;
case 5:
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, 5);
break;
case 6:
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, 7);
break;
case 7:
mpu401_change_addr(ess->mpu, mpu401_base_addr);
mpu401_setirq(ess->mpu, 10);
break;
}
ess->midi_addr = mpu401_base_addr;
io_sethandler(ess->midi_addr, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
break;
case 0x70: /* DAC 2 Sample Rate Divider */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
mixer->regs[mixer->index] = val;
if (ess->dsp.sb_subtype <= SB_SUBTYPE_ESS_ES1868) {
if (val & 0x80)
ess->ess_dac2_freq = (int) (795500UL / (256ul - val));
else
ess->ess_dac2_freq = (int) (397700UL / (128ul - val));
} else {
if (val & 0x80)
ess->ess_dac2_freq = (int) (768000UL / (256ul - val));
else
ess->ess_dac2_freq = (int) (793800UL / (128ul - val));
}
sb_log("ESS DAC2 Samplerate set to %i\n", ess->ess_dac2_freq);
const double temp = 1000000.0 / ess->ess_dac2_freq;
ess->ess_dac2_latcho = ((double) TIMER_USEC * temp);
}
break;
case 0x71: /* DAC 2 Mode */
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869) {
sb_log("ESS DAC2 Mode register write: val = %02X\n", val);
ess->dsp.es1869_divider_mode = (val & 0x20) ? 1 : 0;
mixer->output_filter = (val & 0x04) ? 0 : 1;
mixer->input_filter = (val & 0x04) ? 0 : 1;
mixer->output_filter_dac2 = (val & 0x08) ? 0 : 1;
}
break;
case 0x72: /* DAC 2 Filter Clock Divider */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
mixer->regs[mixer->index] = val;
sb_log("ESS DAC2 filter reg write, val = %02X\n", val);
const double dac2_freq = (7160000.0 / (256.0 - ((double) val))) * 41.0;
const int temp = (int) dac2_freq;
if (ess->ess_dac2_freq != temp)
recalc_ess_dac2_filter(temp);
ess->ess_dac2_freq = temp;
}
break;
case 0x74: /* DAC 2 DMA Reload Counter low byte */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
mixer->regs[mixer->index] = val;
unsigned int c = (unsigned int) (mixer->regs[0x76] << 8U);
c |= (unsigned int) val;
ess->ess_dac2_autolen = (int) (0x10000 - c);
}
break;
case 0x76: /* DAC 2 DMA Reload Counter high byte */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
mixer->regs[mixer->index] = val;
unsigned int c = (unsigned int) (val << 8U);
c |= (unsigned int) mixer->regs[0x74];
ess->ess_dac2_autolen = (int) (0x10000 - c);
}
break;
case 0x78: /* DAC 2 Control 1 */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
mixer->regs[mixer->index] = val;
ess->ess_dac2_autoinit = (val & 0x10);
if (val & 0x02)
ess_dac2_startdma(ess);
if ((val & 0x04) || (val & 0x03) == 0x00) {
ess->ess_dac2_suspend = 1;
if (!ess->ess_dac2_irq) /* Shared IRQ mode */
picintc(1 << ess->dsp.sb_irqnum);
else
picintc(1 << ess->ess_dac2_irq);
}
}
break;
case 0x7a: /* DAC 2 Control 2 */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
mixer->regs[mixer->index] = val;
ess->ess_dac2_16bit = (val & 0x01);
ess->ess_dac2_stereo = (val & 0x02);
ess->ess_dac2_signed = (val & 0x04);
if (!(val & 0x40) || !(val & 0x80)) {
if (!ess->ess_dac2_irq) /* Shared IRQ mode */
picintc(1 << ess->dsp.sb_irqnum);
else
picintc(1 << ess->ess_dac2_irq);
}
if ((val & 0xc0) == 0xc0) { /* DAC2 IRQ test */
sb_log("ESS DAC2 test IRQ fired!\n");
if (!ess->ess_dac2_irq) /* Shared IRQ mode */
picint(1 << ess->dsp.sb_irqnum);
else
picint(1 << ess->ess_dac2_irq);
}
}
break;
case 0x7c: /* DAC 2 Volume */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
sb_log("ESS DAC2 volume write! reg = %02X, val = %02X\n", mixer->index, val);
mixer->regs[mixer->index] = val;
}
break;
case 0x7d: /* DAC 2 Configuration (ES188x) / Mic preamp/MONO_IN/MONO_OUT (ES1869) */
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869)
mixer->regs[mixer->index] = val;
/* Documented in the ES1887 datasheet but appears to apply to (later?) ES1888s as well based on the
register writes performed by the Compaq Presario 224x BIOS */
if ((ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) && (ess->dsp.sb_subtype <= SB_SUBTYPE_ESS_ES1887)) {
switch (val & 0x03) {
default:
break;
case 0x00: /* DRQA */
ess->ess_dac2_dma = 0;
break;
case 0x01: /* DRQB */
ess->ess_dac2_dma = 5;
break;
case 0x02: /* DRQC */
ess->ess_dac2_dma = 6;
break;
case 0x03: /* DRQD */
ess->ess_dac2_dma = 5;
break;
}
sb_log("ESS DAC2 new DMA = %i\n", ess->ess_dac2_dma);
}
break;
case 0x7f: /* Interrupt Control (ES188x) / I2S Interface (ES1869) */
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869)
mixer->regs[mixer->index] = val;
/* Documented in the ES1887 datasheet but appears to apply to (later?) ES1888s as well based on the
register writes performed by the Compaq Presario 224x BIOS */
if ((ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) && (ess->dsp.sb_subtype <= SB_SUBTYPE_ESS_ES1887)) {
val &= 0x0f;
switch ((val >> 1) & 0x07) {
default:
break;
case 0x00: /* ES1888 interrupt mode */
ess->dsp.es188x_irq_mode = 0;
/* Switch sb_irqnum back to what's in ESS DSP register B1h */
switch (ess->dsp.ess_regs[0xB1 - 0xA0] & 0x0C) {
default:
break;
case 0x00:
ess->dsp.sb_irqnum = 2;
break;
case 0x04:
ess->dsp.sb_irqnum = 5;
break;
case 0x08:
ess->dsp.sb_irqnum = 7;
break;
case 0x0C:
ess->dsp.sb_irqnum = 10;
break;
}
switch ((mixer->regs[0x40] >> 5) & 0x7) { /* Switch MPU401 IRQ back to what's in mixer reg 40h */
default:
break;
case 0: case 1:
mpu401_setirq(ess->mpu, -1);
break;
case 2:
mpu401_setirq(ess->mpu, ess->dsp.sb_irqnum);
break;
case 3:
mpu401_setirq(ess->mpu, 11);
break;
case 4:
mpu401_setirq(ess->mpu, 9);
break;
case 5:
mpu401_setirq(ess->mpu, 5);
break;
case 6:
mpu401_setirq(ess->mpu, 7);
break;
case 7:
mpu401_setirq(ess->mpu, 10);
break;
}
break;
case 0x01: /* IRQA */
ess->dsp.es188x_irq_mode = 1;
ess->dsp.sb_irqnum = 9;
mpu401_setirq(ess->mpu, ess->dsp.sb_irqnum);
break;
case 0x02: /* IRQB */
ess->dsp.es188x_irq_mode = 1;
ess->dsp.sb_irqnum = 5;
mpu401_setirq(ess->mpu, ess->dsp.sb_irqnum);
break;
case 0x03: /* IRQC */
ess->dsp.es188x_irq_mode = 1;
ess->dsp.sb_irqnum = 7;
mpu401_setirq(ess->mpu, ess->dsp.sb_irqnum);
break;
case 0x04: /* IRQD */
ess->dsp.es188x_irq_mode = 1;
ess->dsp.sb_irqnum = 10;
mpu401_setirq(ess->mpu, ess->dsp.sb_irqnum);
break;
case 0x05: /* IRQE */
ess->dsp.es188x_irq_mode = 1;
ess->dsp.sb_irqnum = 11;
mpu401_setirq(ess->mpu, ess->dsp.sb_irqnum);
break;
case 0x06: case 0x07: /* Reserved */
break;
}
sb_log("ESS ES188x new IRQ mode %sabled, IRQ now %i\n", ess->dsp.es188x_irq_mode ? "En" : "Dis", ess->dsp.sb_irqnum);
}
break;
default:
sb_log("ess: Unknown mixer register WRITE: %02X\t%02X\n",
mixer->index, mixer->regs[mixer->index]);
break;
}
}
mixer->voice_l = sb_att_2dbstep_4bits[(mixer->regs[0x14] >> 4) & 0x0F] / 32767.0;
mixer->voice_r = sb_att_2dbstep_4bits[mixer->regs[0x14] & 0x0F] / 32767.0;
mixer->master_l = sb_att_2dbstep_4bits[(mixer->regs[0x32] >> 4) & 0x0F] / 32767.0;
mixer->master_r = sb_att_2dbstep_4bits[mixer->regs[0x32] & 0x0F] / 32767.0;
mixer->fm_l = sb_att_2dbstep_4bits[(mixer->regs[0x36] >> 4) & 0x0F] / 32767.0;
mixer->fm_r = sb_att_2dbstep_4bits[mixer->regs[0x36] & 0x0F] / 32767.0;
mixer->cd_l = sb_att_2dbstep_4bits[(mixer->regs[0x38] >> 4) & 0x0F] / 32767.0;
mixer->cd_r = sb_att_2dbstep_4bits[mixer->regs[0x38] & 0x0F] / 32767.0;
mixer->auxb_l = sb_att_2dbstep_4bits[(mixer->regs[0x3a] >> 4) & 0x0F] / 32767.0;
mixer->auxb_r = sb_att_2dbstep_4bits[mixer->regs[0x3a] & 0x0F] / 32767.0;
mixer->line_l = sb_att_2dbstep_4bits[(mixer->regs[0x3e] >> 4) & 0x0F] / 32767.0;
mixer->line_r = sb_att_2dbstep_4bits[mixer->regs[0x3e] & 0x0F] / 32767.0;
mixer->speaker = sb_att_3dbstep_3bits[mixer->regs[0x3c] & 0x07] / 32767.0;
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788) {
mixer->master_l = mixer->regs[0x60] & 0x40 ? 0 : (ess_att_6bits[mixer->regs[0x60] & 0x3F] / 32767.0);
mixer->master_r = mixer->regs[0x62] & 0x40 ? 0 : (ess_att_6bits[mixer->regs[0x62] & 0x3F] / 32767.0);
}
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
if (ess->dsp.sb_subtype != SB_SUBTYPE_ESS_ES1868) {
mixer->dac2_l = sb_att_2dbstep_4bits[(mixer->regs[0x7c] >> 4) & 0x0F] / 32767.0;
mixer->dac2_r = sb_att_2dbstep_4bits[mixer->regs[0x7c] & 0x0F] / 32767.0;
} else { /* ES1868 does not have the DAC2 volume register */
mixer->dac2_l = mixer->voice_l;
mixer->dac2_r = mixer->voice_r;
}
}
}
}
static void
ess_solo1_mixer_recalc(sb_t *ess)
{
ess_mixer_t *mixer;
if (ess == NULL)
return;
mixer = &ess->mixer_ess;
mixer->voice_l = ess_solo1_4bit_gain(ess_solo1_audio1_db,
(mixer->regs[0x14] >> 4) & 0x0f);
mixer->voice_r = ess_solo1_4bit_gain(ess_solo1_audio1_db,
mixer->regs[0x14] & 0x0f);
mixer->fm_l = ess_solo1_4bit_gain(ess_solo1_music_db,
(mixer->regs[0x36] >> 4) & 0x0f);
mixer->fm_r = ess_solo1_4bit_gain(ess_solo1_music_db,
mixer->regs[0x36] & 0x0f);
mixer->cd_l = ess_solo1_4bit_gain(ess_solo1_aux_db,
(mixer->regs[0x38] >> 4) & 0x0f);
mixer->cd_r = ess_solo1_4bit_gain(ess_solo1_aux_db,
mixer->regs[0x38] & 0x0f);
mixer->dac2_l = ess_solo1_4bit_gain(ess_solo1_audio2_db,
(mixer->regs[0x7c] >> 4) & 0x0f);
mixer->dac2_r = ess_solo1_4bit_gain(ess_solo1_audio2_db,
mixer->regs[0x7c] & 0x0f);
mixer->master_l = ess_solo1_master_gain(mixer->regs[0x60]);
mixer->master_r = ess_solo1_master_gain(mixer->regs[0x62]);
}
static void
ess_solo1_mixer_set_reset_defaults(sb_t *ess)
{
ess_mixer_t *mixer;
if (ess == NULL)
return;
mixer = &ess->mixer_ess;
mixer->regs[0x14] = 0x88; /* Audio 1 play volume. */
mixer->regs[0x32] = 0x88; /* Backward-compatible master volume. */
mixer->regs[0x36] = 0x88; /* Music DAC / ESFM volume. */
mixer->regs[0x38] = 0x00; /* AuxA / CD muted at reset. */
mixer->regs[0x3a] = 0x00;
mixer->regs[0x3c] = 0x04;
mixer->regs[0x3e] = 0x00;
mixer->regs[0x60] = 0x36; /* Actual left master hardware volume. */
mixer->regs[0x62] = 0x36; /* Actual right master hardware volume. */
mixer->regs[0x64] = 0x00; /* SB Pro master-volume emulation enabled. */
mixer->regs[0x7c] = 0x00; /* Audio 2 playback muted at reset. */
}
static void
ess_solo1_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *ess = (sb_t *) priv;
int mixer_reset = 0;
if (ess != NULL && (addr & 1) && ess->mixer_ess.index == 0x00)
mixer_reset = 1;
ess_mixer_write(addr, val, priv);
if (ess != NULL && (addr & 1)) {
if (mixer_reset)
ess_solo1_mixer_set_reset_defaults(ess);
ess_solo1_mixer_recalc(ess);
}
}
uint8_t
ess_mixer_read(uint16_t addr, void *priv)
{
sb_t *ess = (sb_t *) priv;
const ess_mixer_t *mixer = &ess->mixer_ess;
uint8_t ret = 0x0a;
if (!(addr & 1))
ret = mixer->index;
else
switch (mixer->index) {
case 0x00:
case 0x0a:
case 0x0c:
case 0x0e:
case 0x14:
case 0x1a:
case 0x02:
case 0x06:
case 0x30:
case 0x36:
case 0x38:
case 0x3a:
case 0x3e:
ret = mixer->regs[mixer->index];
break;
case 0x04:
case 0x26:
case 0x28:
case 0x2e:
ret = mixer->regs[mixer->index] | 0x11;
break;
case 0x22:
ret = mixer->regs[mixer->index] | 0x11;
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788) {
ret = 0x00;
/* ES1788+ translates the master volume (regs 60/62h) when the SBPro master volume is read */
if (mixer->regs[0x60] & 0x40)
ret = 0x10;
else
ret = (ess_sbpro_6bit_xlat[(mixer->regs[0x60] & 0x3f)] << 4);
if (mixer->regs[0x62] & 0x40)
ret |= 0x01;
else
ret |= ess_sbpro_6bit_xlat[(mixer->regs[0x62] & 0x3f)];
}
break;
case 0x32:
ret = mixer->regs[mixer->index];
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788) {
ret = 0x00;
/* ES1788+ translates the master volume (regs 60/62h) when the 4-bit ESS master volume is read */
if (mixer->regs[0x60] & 0x40)
ret = 0x00;
else
ret = (ess_6bit_xlat[(mixer->regs[0x60] & 0x3f)] << 4);
if (mixer->regs[0x62] & 0x40)
ret |= 0x00;
else
ret |= ess_6bit_xlat[(mixer->regs[0x62] & 0x3f)];
}
break;
/* Bit 1 always set, bits 7-6 always clear on both the real ES688 and ES1688. */
case 0x1c:
ret = mixer->regs[mixer->index] | 0x10;
break;
/*
Real ES688: Always 0x00;
Real ES1688: Bit 2 always clear.
*/
case 0x40:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1868) {
switch (ess->es186x_id_state) {
default:
break;
case 0:
ret = 0x18;
ess->es186x_id_state = 1;
break;
case 1:
ret = (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869) ? 0x69 : 0x68;
ess->es186x_id_state = 2;
break;
case 2:
ret = (ess->es186x_ctrl_addr >> 8) & 0x0f;
ess->es186x_id_state = 3;
break;
case 3:
ret = ess->es186x_ctrl_addr & 0xff;
ess->es186x_id_state = 0;
break;
}
} else if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788)
ret = mixer->regs[mixer->index];
else if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1688)
ret = mixer->regs[mixer->index] & 0xfb;
else
ret = 0x00;
break;
/*
Real ES688: Always 0x00;
Real ES1688: All bits writable.
*/
case 0x48:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1688)
ret = mixer->regs[mixer->index];
else
ret = 0x00;
break;
/* ES1788+ 6-bit master volume */
case 0x60:
case 0x62:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788)
ret = mixer->regs[mixer->index];
break;
/*
Return 0x00 so it has bit 3 clear, so NT 5.x drivers don't misdetect it as ES1788.
Bit 3 set and writable: ESSCFG detects the card as ES1788 if register 70h is read-only,
otherwise, as ES1887.
Bit 3 set and read-only: ESSCFG detects the card as ES1788 if register 70h is read-only,
otherwise, as ES1888.
Real ES688 and ES1688: Always 0x00.
*/
case 0x64:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1887)
ret = (mixer->regs[mixer->index] & 0xff);
else if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1788)
/* ES1788, ES1888 based on datasheet */
ret = (mixer->regs[mixer->index]) | 0x28;
else
ret = 0x00;
break;
case 0x70:
case 0x71:
case 0x72:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888)
ret = mixer->regs[mixer->index];
break;
case 0x74:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
if (ess->ess_dac2_suspend)
ret = ess->ess_dac2_counter & 0xff;
else
ret = mixer->regs[mixer->index];
}
break;
case 0x76:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
if (ess->ess_dac2_suspend)
ret = (ess->ess_dac2_counter >> 8) & 0xff;
else
ret = mixer->regs[mixer->index];
}
break;
case 0x78:
case 0x7a:
case 0x7c:
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888)
ret = mixer->regs[mixer->index];
break;
case 0x7d:
if ((ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869) || ((ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) && (ess->dsp.sb_subtype <= SB_SUBTYPE_ESS_ES1887)))
ret = mixer->regs[mixer->index];
break;
case 0x7f:
if ((ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) && (ess->dsp.sb_subtype <= SB_SUBTYPE_ESS_ES1887)) {
uint8_t temp = 0;
temp = ((ess->dsp.sb_irq8 || ess->dsp.sb_irq16) ? 0x10: 0) | ((mixer->regs[0x7a] & 0x80) ? 0x20 : 0) | ((ess->dsp.sb_irq401 || ess->mpu->queue_used) ? 0x80 : 0);
ret = (mixer->regs[mixer->index] & 0x0f) | (temp & 0xf0);
} else if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869)
ret = mixer->regs[mixer->index];
break;
default:
sb_log("ess: Unknown mixer register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
break;
}
sb_log("[%04X:%08X] [R] %04X = %02X (%02X)\n", CS, cpu_state.pc, addr, ret, mixer->index);
return ret;
}
void
ess_mixer_reset(sb_t *ess)
{
ess_mixer_write(4, 0, ess);
ess_mixer_write(5, 0, ess);
}
static void
ess_solo1_mixer_reset(sb_t *ess)
{
/* Preserve all generic reset side effects, then impose Solo-1 reset state. */
ess_mixer_reset(ess);
ess_solo1_mixer_set_reset_defaults(ess);
ess_solo1_mixer_recalc(ess);
}
void
ess_rsk_reset(void *priv)
{
sb_t *ess = (sb_t *) priv;
uint16_t dspaddr = ess->dsp.sb_addr;
io_removehandler(dspaddr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(dspaddr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(dspaddr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(ess->opl_pnp_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(ess->opl_pnp_addr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, 0);
io_sethandler(0x220, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x229, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x22b, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x22d, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x22f, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x230, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x240, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x250, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1887) {
io_sethandler(0x200, 0x0004, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x388, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x398, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x3a8, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x3b8, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
}
ess->ess_readseq_state = 0;
}
static uint8_t
ess_rsk_read(uint16_t addr, void *priv)
{
sb_t *ess = (sb_t *) priv;
uint8_t ret = 0xff;
switch (ess->ess_readseq_state) {
case 0:
if (addr == 0x229) {
ess->ess_readseq_state = 1;
ess->ess_readseq_mode = 0;
return ret;
} else if ((addr == 0x22b) && (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1887)) {
ess->ess_readseq_state = 1;
ess->ess_readseq_mode = 1;
return ret;
}
break;
case 1:
if (addr == 0x229) {
ess->ess_readseq_state = 2;
return ret;
}
break;
case 2:
if ((addr == 0x229) || ((addr == 0x22f) && ess->ess_readseq_mode)) {
ess->ess_readseq_state = 3;
return ret;
}
break;
case 3:
if ((addr == 0x22b) || ((addr == 0x22d) && ess->ess_readseq_mode)) {
ess->ess_readseq_state = 4;
return ret;
}
break;
case 4:
if ((addr == 0x229) || ((addr == 0x22d) && ess->ess_readseq_mode)) {
ess->ess_readseq_state = 5;
return ret;
}
break;
case 5:
if ((addr == 0x22b) || ((addr == 0x22f) && ess->ess_readseq_mode)) {
ess->ess_readseq_state = 6;
return ret;
}
break;
case 6:
if (addr == 0x229) {
ess->ess_readseq_state = 7;
return ret;
}
break;
case 7:
if ((addr == 0x229) && !ess->ess_readseq_mode) {
ess->ess_readseq_state = 8;
return ret;
} else if (ess->ess_readseq_mode && ((addr == 0x220) || (addr == 0x230) || (addr == 0x240) || (addr == 0x250))) {
ess->ess_dsp_addr = addr;
sb_log("ES1887 Read-Sequence-Key: new DSP addr = %04X\n", ess->ess_dsp_addr);
ess->ess_readseq_state = 8;
return ret;
}
break;
case 8:
if ((addr == 0x22b) && !ess->ess_readseq_mode) {
ess->ess_readseq_state = 9;
return ret;
} else if (ess->ess_readseq_mode && ((addr >= 0x200) && (addr <= 0x203))) {
ess->gameport_addr = addr;
sb_log("ES1887 Read-Sequence-Key: new gameport addr = %04X\n", ess->gameport_addr);
ess->ess_readseq_state = 9;
return ret;
} else if (ess->ess_readseq_mode) {
ess->gameport_addr = 0;
sb_log("ES1887 Read-Sequence-Key: new gameport addr = %04X\n", ess->gameport_addr);
ess->ess_readseq_state = 9;
return ret;
}
break;
case 9:
if (addr == 0x229) {
ess->ess_readseq_state = 10;
return ret;
} else if (ess->ess_readseq_mode && ((addr == 0x388) || (addr == 0x398) || (addr == 0x3a8) || (addr == 0x3b8))) {
ess->opl_pnp_addr = addr;
sb_log("ES1887 Read-Sequence-Key: new OPL addr = %04X\n", ess->opl_pnp_addr);
ess->ess_readseq_state = 11;
} else if (ess->ess_readseq_mode) {
ess->opl_pnp_addr = 0x388;
sb_log("ES1887 Read-Sequence-Key: new OPL addr = %04X\n", ess->opl_pnp_addr);
ess->ess_readseq_state = 11;
}
break;
case 10:
if ((addr == 0x220) || (addr == 0x230) || (addr == 0x240) || (addr == 0x250)) {
ess->ess_readseq_state = 11;
ess->ess_dsp_addr = addr;
sb_log("ESS Read-Sequence-Key complete, new addr = %04X\n", ess->ess_dsp_addr);
}
break;
default:
ess->ess_readseq_state = 0;
break;
}
if (ess->ess_readseq_state != 11)
return ret;
else {
io_removehandler(0x220, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x229, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x22b, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x22d, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x22f, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x230, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x240, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x250, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1887) {
io_removehandler(0x200, 0x0004, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x388, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x398, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x3a8, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_removehandler(0x3b8, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
}
io_sethandler(ess->ess_dsp_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->ess_dsp_addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->ess_dsp_addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(ess->ess_dsp_addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, ess->ess_dsp_addr);
sb_log("ESS DSP set to addr %04X\n", ess->ess_dsp_addr);
io_sethandler(ess->ess_dsp_addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(ess->ess_dsp_addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(ess->ess_dsp_addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(ess->opl_pnp_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->opl_pnp_addr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
ess->ess_readseq_state = 12;
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1887)
gameport_remap(ess->gameport, ess->gameport_addr);
}
return ret;
}
static void
ess_scr_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *ess = (sb_t *) priv;
uint16_t dspaddr = ess->dsp.sb_addr;
uint16_t opladdr = ess->opl_pnp_addr;
if (addr == 0x00fb) {
ess->ess_scr_locked = 0;
//sb_log("ESS System Config unlocked\n");
return;
}
if (addr == 0x00f9) {
ess->ess_scr_locked = 1;
//sb_log("ESS System Config locked\n");
return;
}
if (ess->ess_scr_locked)
return;
switch (addr & 0x0001) {
default:
case 0x0000:
break;
case 0x0001:
io_removehandler(dspaddr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(dspaddr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(dspaddr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(dspaddr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(opladdr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(opladdr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, 0);
switch (val & 0x03) {
default:
break;
case 0x00:
dspaddr = 0x220;
break;
case 0x01:
dspaddr = 0x230;
break;
case 0x02:
dspaddr = 0x240;
break;
case 0x03:
dspaddr = 0x250;
break;
}
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1887) {
switch ((val >> 6) & 0x03) {
default:
break;
case 0x00:
opladdr = 0x388;
break;
case 0x01:
opladdr = 0x398;
break;
case 0x02:
opladdr = 0x3a8;
break;
case 0x03:
opladdr = 0x3b8;
break;
}
ess->opl_pnp_addr = opladdr;
switch ((val >> 4) & 0x03) {
default:
break;
case 0x00:
ess->gameport_addr = 0x200;
break;
case 0x01:
ess->gameport_addr = 0x201;
break;
case 0x02:
ess->gameport_addr = 0x202;
break;
case 0x03:
ess->gameport_addr = 0x203;
break;
}
gameport_remap(ess->gameport, (val & 0x08) ? ess->gameport_addr : 0);
}
if (val & 0x04) {
io_sethandler(dspaddr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(dspaddr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(dspaddr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(dspaddr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, dspaddr);
io_sethandler(dspaddr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(dspaddr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(dspaddr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(opladdr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(opladdr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
break;
}
sb_log("ESS System Config write! addr = %04X, val = %02X\n", addr, val);
}
static void ess_186x_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv);
static void
ess_pnp_control_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *ess = (sb_t *) priv;
uint8_t ldn = ess->es186x_ctrl_iregs[7];
switch (addr & 0x07) {
/* Configuration Register address/data are a backdoor method of accessing the
ISAPnP Logical Device Registers */
case 0: /* Configuration Register Address */
ess->es186x_ctrl_regs[0] = val;
break;
case 1: /* Configuration Register Data */
ess->es186x_ctrl_iregs[ess->es186x_ctrl_regs[0]] = val;
isapnp_write_reg(ess->pnp_card, ldn, ess->es186x_ctrl_regs[0], val);
break;
case 2: /* EEPROM data register */
break;
case 3: /* EEPROM command register */
ess->es186x_ctrl_regs[3] = val;
break;
case 4: /* Reset EEPROM address */
ess->es186x_rom_pos = 0;
break;
case 5: /* Status Register */
case 6: /* Interrupt Status Register (RO) */
break;
case 7: /* Interrupt Mask Register */
ess->es186x_ctrl_regs[7] = val;
break;
default:
break;
}
sb_log("ESS Control register write! addr = %04X, val = %02X\n", addr, val);
}
uint8_t
ess_pnp_control_read(const uint16_t port, void *priv)
{
sb_t *ess = (sb_t *) priv;
uint8_t ret = 0xff;
uint8_t ldn = ess->es186x_ctrl_iregs[7];
switch (port & 0x07) {
case 0: /* Configuration Register Address */
ret = ess->es186x_ctrl_regs[0];
break;
case 1: /* Configuration Register Data */
if (ess->es186x_ctrl_regs[0] == 0x25)
ret = 0x02;
else
ret = isapnp_read_reg(ess->pnp_card, ldn, ess->es186x_ctrl_regs[0]);
break;
case 2: /* EEPROM data register */
if ((ess->es186x_ctrl_regs[3] & 0x0f) == 0x08) {
if (ess->es186x_rom_pos < 8)
ret = es1868_header[ess->es186x_rom_pos];
else
ret = ess->pnp_rom[ess->es186x_rom_pos - 8];
ess->es186x_rom_pos++;
ess->es186x_rom_pos &= 0x1ff;
}
break;
case 3: /* EEPROM command register */
ret = ess->es186x_ctrl_regs[3];
break;
case 4: /* Reset EEPROM address */
break;
case 5: /* Status Register */
ret = 0x02;
break;
case 6: /* Interrupt Status Register (RO) */
ret = ((ess->dsp.sb_irq8 || ess->dsp.sb_irq16) ? 0x01 : 0) | ((ess->mixer_ess.regs[0x7a] & 0x80) ? 0x02 : 0) | ((ess->dsp.sb_irq401 || ess->mpu->queue_used) ? 0x08 : 0);
break;
case 7: /* Interrupt Mask Register */
ret = ess->es186x_ctrl_regs[7];
break;
default:
break;
}
sb_log("ESS Control register read! addr = %04X, ret = %02X\n", port, ret);
return ret;
}
uint8_t
sb_mcv_read(const uint16_t port, void *priv)
{
const sb_t *sb = (sb_t *) priv;
sb_log("sb_mcv_read: port=%04x\n", port);
return sb->pos_regs[port & 7];
}
void
sb_mcv_write(const uint16_t port, uint8_t val, void *priv)
{
uint16_t addr = 0;
sb_t *sb = (sb_t *) priv;
if (port < 0x102)
return;
sb_log("sb_mcv_write: port=%04x val=%02x\n", port, val);
addr = sb_mcv_addr[sb->pos_regs[4] & 7];
if (sb->opl_enabled) {
io_removehandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(0x0388, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&sb->dsp, 0);
sb->pos_regs[port & 7] = val;
if (sb->pos_regs[2] & 1) {
addr = sb_mcv_addr[sb->pos_regs[4] & 7];
if (sb->opl_enabled) {
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&sb->dsp, addr);
}
}
uint8_t
sb_mcv_feedb(void *priv)
{
const sb_t *sb = (sb_t *) priv;
return (sb->pos_regs[2] & 1);
}
static uint8_t
sb_pro_mcv_read(const uint16_t port, void *priv)
{
const sb_t *sb = (sb_t *) priv;
uint8_t ret = sb->pos_regs[port & 7];
sb_log("sb_pro_mcv_read: port=%04x ret=%02x\n", port, ret);
return ret;
}
static void
sb_pro_mcv_write(const uint16_t port, uint8_t val, void *priv)
{
uint16_t addr = 0;
sb_t *sb = (sb_t *) priv;
if (port < 0x102)
return;
sb_log("sb_pro_mcv_write: port=%04x val=%02x\n", port, val);
addr = (sb->pos_regs[2] & 0x20) ? 0x220 : 0x240;
io_removehandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(0x0388, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 4, 0x0002,
sb_ct1345_mixer_read, NULL, NULL,
sb_ct1345_mixer_write, NULL, NULL,
sb);
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&sb->dsp, 0);
sb->pos_regs[port & 7] = val;
if (sb->pos_regs[2] & 1) {
addr = (sb->pos_regs[2] & 0x20) ? 0x220 : 0x240;
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL, sb->opl.priv);
io_sethandler(addr + 4, 0x0002,
sb_ct1345_mixer_read, NULL, NULL,
sb_ct1345_mixer_write, NULL, NULL,
sb);
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&sb->dsp, addr);
}
sb_dsp_setirq(&sb->dsp, sb_pro_mcv_irqs[(sb->pos_regs[5] >> 4) & 3]);
sb_dsp_setdma8(&sb->dsp, sb->pos_regs[4] & 3);
}
static uint8_t
sb_16_reply_mca_read(const uint16_t port, void *priv)
{
const sb_t *sb = (sb_t *) priv;
uint8_t ret = sb->pos_regs[port & 7];
sb_log("sb_16_reply_mca_read: port=%04x ret=%02x\n", port, ret);
return ret;
}
static void
sb_16_reply_mca_write(const uint16_t port, const uint8_t val, void *priv)
{
uint16_t addr = 0;
sb_t *sb = (sb_t *) priv;
if (port < 0x102)
return;
sb_log("sb_16_reply_mca_write: port=%04x val=%02x\n", port, val);
switch (sb->pos_regs[2] & 0xc4) {
case 4:
addr = 0x220;
break;
case 0x44:
addr = 0x240;
break;
case 0x84:
addr = 0x260;
break;
case 0xc4:
addr = 0x280;
break;
case 0:
default:
addr = 0;
break;
}
if (addr) {
io_removehandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(0x0388, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&sb->dsp, 0);
mpu401_change_addr(sb->mpu, 0);
gameport_remap(sb->gameport, 0);
sb->pos_regs[port & 7] = val;
if (sb->pos_regs[2] & 1) {
uint16_t mpu401_addr;
switch (sb->pos_regs[2] & 0xc4) {
case 4:
addr = 0x220;
break;
case 0x44:
addr = 0x240;
break;
case 0x84:
addr = 0x260;
break;
case 0xc4:
addr = 0x280;
break;
case 0:
default:
addr = 0;
break;
}
switch (sb->pos_regs[2] & 0x18) {
case 8:
mpu401_addr = 0x330;
break;
case 0x18:
mpu401_addr = 0x300;
break;
case 0:
default:
mpu401_addr = 0;
break;
}
if (addr) {
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL, sb->opl.priv);
io_sethandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&sb->dsp, addr);
mpu401_change_addr(sb->mpu, mpu401_addr);
gameport_remap(sb->gameport, (sb->pos_regs[2] & 0x20) ? 0x200 : 0);
}
switch (sb->pos_regs[4] & 0x60) {
case 0x20:
sb_dsp_setirq(&sb->dsp, 5);
break;
case 0x40:
sb_dsp_setirq(&sb->dsp, 7);
break;
case 0x60:
sb_dsp_setirq(&sb->dsp, 10);
break;
default:
break;
}
const int low_dma = sb->pos_regs[3] & 3;
int high_dma = (sb->pos_regs[3] >> 4) & 7;
if (!high_dma)
high_dma = low_dma;
sb_dsp_setdma8(&sb->dsp, low_dma);
sb_dsp_setdma16(&sb->dsp, high_dma);
}
void
sb_vibra16s_onboard_relocate_base(uint16_t new_addr, void *priv)
{
sb_t *sb = (sb_t *) priv;
uint16_t addr = sb->dsp.sb_addr;
if (addr != 0x0000) {
io_removehandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
}
sb_dsp_setaddr(&sb->dsp, 0);
addr = new_addr;
if (addr != 0x0000) {
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
}
sb_dsp_setaddr(&sb->dsp, addr);
}
static void
sb_16_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
{
sb_t *sb = (sb_t *) priv;
uint16_t addr = sb->dsp.sb_addr;
switch (ld) {
default:
case 4: /* StereoEnhance (32) */
break;
case 0: /* Audio */
io_removehandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_removehandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
addr = sb->opl_pnp_addr;
if (addr) {
sb->opl_pnp_addr = 0;
io_removehandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
sb_dsp_setaddr(&sb->dsp, 0);
sb_dsp_setirq(&sb->dsp, 0);
sb_dsp_setdma8(&sb->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED);
mpu401_change_addr(sb->mpu, 0);
if (config->activate) {
uint8_t val = config->irq[0].irq;
addr = config->io[0].base;
if (addr != ISAPNP_IO_DISABLED) {
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 4, 0x0002,
sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL,
sb);
sb_dsp_setaddr(&sb->dsp, addr);
}
addr = config->io[1].base;
if (addr != ISAPNP_IO_DISABLED)
mpu401_change_addr(sb->mpu, addr);
addr = config->io[2].base;
if (addr != ISAPNP_IO_DISABLED) {
sb->opl_pnp_addr = addr;
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
if (val != ISAPNP_IRQ_DISABLED)
sb_dsp_setirq(&sb->dsp, val);
val = config->dma[0].dma;
if (val != ISAPNP_DMA_DISABLED)
sb_dsp_setdma8(&sb->dsp, val);
val = config->dma[1].dma;
sb_dsp_setdma16_enabled(&sb->dsp, val != ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_translate(&sb->dsp, val < ISAPNP_DMA_DISABLED);
if (val != ISAPNP_DMA_DISABLED) {
if (sb->dsp.sb_16_dma_supported)
sb_dsp_setdma16(&sb->dsp, val);
else
sb_dsp_setdma16_8(&sb->dsp, val);
}
}
break;
case 1: /* IDE */
if (sb->has_ide)
ide_pnp_config_changed(0, config, (void *) 3);
break;
case 2: /* Reserved (16) / WaveTable (32+) */
if (sb->dsp.sb_type >= SBAWE32_DSP_412)
emu8k_change_addr(&sb->emu8k, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
break;
case 3: /* Game */
gameport_remap(sb->gameport, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
break;
}
}
static void
sb_vibra16_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
{
sb_t *sb = (sb_t *) priv;
switch (ld) {
case 0: /* Audio */
case 1: /* Game */
sb_16_pnp_config_changed(ld * 3, config, sb);
break;
default:
break;
}
}
static void
goldfinch_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
{
goldfinch_t *goldfinch = (goldfinch_t *) priv;
if (ld == 0)
/* WaveTable */
emu8k_change_addr(&goldfinch->emu8k, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
}
static void
sb_awe32_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
{
sb_t *sb = (sb_t *) priv;
switch (ld) {
case 0: /* Audio */
case 1: /* IDE */
sb_16_pnp_config_changed(ld, config, sb);
break;
case 2: /* Game */
case 3: /* WaveTable */
sb_16_pnp_config_changed(ld ^ 1, config, sb);
break;
default:
break;
}
}
static void
sb_awe64_pnp_ide_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
{
sb_t *sb = (sb_t *) priv;
switch (ld) {
case 0: /* Audio */
case 2: /* WaveTable */
sb_16_pnp_config_changed(ld, config, sb);
break;
case 1: /* Game */
case 3: /* IDE */
sb_16_pnp_config_changed(ld ^ 2, config, sb);
break;
default:
break;
}
}
static void
sb_awe64_pnp_noide_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
{
sb_t *sb = (sb_t *) priv;
switch (ld) {
case 0: /* Audio */
case 2: /* WaveTable */
sb_16_pnp_config_changed(ld, config, sb);
break;
case 1: /* Game */
sb_16_pnp_config_changed(3, config, sb);
break;
default:
break;
}
}
static void
ess_x688_pnp_config_changed(UNUSED(const uint8_t ld), isapnp_device_config_t *config, void *priv)
{
sb_t *ess = (sb_t *) priv;
uint16_t addr = ess->dsp.sb_addr;
uint8_t val;
switch (ld) {
case 0: /* Audio */
io_removehandler(addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_removehandler(addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
addr = ess->opl_pnp_addr;
if (addr) {
ess->opl_pnp_addr = 0;
io_removehandler(addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(addr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
if (ess->pnp == 3) {
addr = ess->midi_addr;
if (addr) {
ess->midi_addr = 0;
if (ess->mpu != NULL)
mpu401_change_addr(ess->mpu, 0);
io_removehandler(addr, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
}
sb_dsp_setaddr(&ess->dsp, 0);
sb_dsp_setirq(&ess->dsp, 0);
if ((ess->pnp == 3) && (ess->mpu != NULL))
mpu401_setirq(ess->mpu, -1);
sb_dsp_setdma8(&ess->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_8(&ess->dsp, ISAPNP_DMA_DISABLED);
if (config->activate) {
addr = config->io[0].base;
if (addr != ISAPNP_IO_DISABLED) {
io_sethandler(addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, addr);
io_sethandler(addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
}
addr = config->io[1].base;
if (addr != ISAPNP_IO_DISABLED) {
ess->opl_pnp_addr = addr;
io_sethandler(addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
if (ess->pnp == 3) {
addr = config->io[2].base;
if (addr != ISAPNP_IO_DISABLED) {
if (ess->mpu != NULL)
mpu401_change_addr(ess->mpu, addr);
io_sethandler(addr, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
}
val = config->irq[0].irq;
if (val != ISAPNP_IRQ_DISABLED) {
sb_dsp_setirq(&ess->dsp, val);
if ((ess->pnp == 3) && (ess->mpu != NULL))
mpu401_setirq(ess->mpu, val);
}
val = config->dma[0].dma;
if (val != ISAPNP_DMA_DISABLED) {
sb_dsp_setdma8(&ess->dsp, val);
sb_dsp_setdma16_8(&ess->dsp, val);
}
}
break;
case 1:
if (ess->pnp == 3) { /* Game */
gameport_remap(ess->gameport, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
} else if (ess->mpu != NULL) { /* MPU-401 */
mpu401_change_addr(ess->mpu, 0);
mpu401_setirq(ess->mpu, -1);
if (config->activate) {
addr = config->io[0].base;
if (addr != ISAPNP_IO_DISABLED)
mpu401_change_addr(ess->mpu, addr);
val = config->irq[0].irq;
if (val != ISAPNP_IRQ_DISABLED)
mpu401_setirq(ess->mpu, val);
}
}
break;
case 2:
if (ess->pnp == 3) /* IDE */
ide_pnp_config_changed_1addr(0, config, (void *) 3);
else /* Game */
gameport_remap(ess->gameport, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
break;
case 3:
if (ess->pnp <= 2) /* IDE */
ide_pnp_config_changed_1addr(0, config, (void *) 3);
break;
default:
break;
}
}
static void
ess_186x_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
{
sb_t *ess = (sb_t *) priv;
uint16_t addr = ess->dsp.sb_addr;
uint16_t ctrladdr = ess->es186x_ctrl_addr;
uint16_t opladdr = ess->opl_pnp_addr;
uint16_t mpuaddr = ess->midi_addr;
uint8_t val;
switch (ld) {
case 0: /* Control registers */
if (ctrladdr) {
io_removehandler(ctrladdr, 0x0008, ess_pnp_control_read, NULL, NULL, ess_pnp_control_write, NULL, NULL, ess);
ctrladdr = 0;
}
if (config->activate) {
if (config->io[0].base != ISAPNP_IO_DISABLED) {
ctrladdr = config->io[0].base;
ess->es186x_ctrl_addr = ctrladdr;
sb_log("Updating ES186x Control port, addr = %04X\n", ctrladdr);
io_sethandler(ctrladdr, 0x0008, ess_pnp_control_read, NULL, NULL, ess_pnp_control_write, NULL, NULL, ess);
}
}
break;
case 1: /* Audio */
sb_log("ES186x Audio config change! SB addr = %04X, OPL addr = %04X, MPU addr = %04X\n", addr, opladdr, mpuaddr);
if (addr) {
io_removehandler(addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, 0);
io_removehandler(addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
addr = 0;
}
if (opladdr) {
ess->opl_pnp_addr = 0;
io_removehandler(opladdr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(opladdr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
if (mpuaddr) {
ess->midi_addr = 0;
if (ess->mpu != NULL)
mpu401_change_addr(ess->mpu, 0);
io_removehandler(mpuaddr, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
if (config->activate) {
if (config->io[0].base != ISAPNP_IO_DISABLED) {
addr = config->io[0].base;
io_sethandler(addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, addr);
io_sethandler(addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
sb_log("Updating ES186x SB DSP port, addr = %04X\n", addr);
}
if (config->io[1].base != ISAPNP_IO_DISABLED ) {
ess->opl_pnp_addr = config->io[1].base;
opladdr = ess->opl_pnp_addr;
io_sethandler(opladdr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(opladdr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
sb_log("Updating ES186x OPL port, addr = %04X\n", opladdr);
}
if ((config->io[2].base != ISAPNP_IO_DISABLED) && (config->io[2].base != 0xFFFF)) { /* NT 3.5x driver sets an invalid value when MPU401 is disabled */
ess->midi_addr = config->io[2].base;
mpuaddr = ess->midi_addr;
if (ess->mpu != NULL)
mpu401_change_addr(ess->mpu, mpuaddr);
io_sethandler(mpuaddr, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
sb_log("Updating ES186x MPU401 port, addr = %04X\n", mpuaddr);
}
val = config->irq[0].irq;
if (val != ISAPNP_IRQ_DISABLED) {
sb_dsp_setirq(&ess->dsp, val);
if ((ess->mpu != NULL))
mpu401_setirq(ess->mpu, val);
ess->dsp.es188x_irq_mode = 1;
ess->ess_dac2_irq = 0;
sb_log("Updating ES186x IRQ, new IRQ is %i\n", val);
}
val = config->dma[0].dma;
if (val != ISAPNP_DMA_DISABLED) {
sb_dsp_setdma8(&ess->dsp, val);
sb_dsp_setdma16_8(&ess->dsp, val);
sb_log("Updating ES186x DAC1 DMA, new DMA is %i\n", val);
}
val = config->dma[1].dma;
if (val != ISAPNP_DMA_DISABLED) {
ess->ess_dac2_dma = config->dma[1].dma;
sb_log("Updating ES186x DAC2 DMA, new DMA is %i\n", val);
}
}
break;
case 2: /* Joystick */
gameport_remap(ess->gameport, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
break;
case 3: /* IDE */
if (ess->has_ide)
ide_pnp_config_changed_1addr(0, config, (void *) 3);
break;
default:
break;
}
}
/* This function is common to all the ESS MCA cards. */
static uint8_t
ess_x688_mca_read(const uint16_t port, void *priv)
{
const sb_t *ess = (sb_t *) priv;
const uint8_t ret = ess->pos_regs[port & 7];
sb_log("ess_mca_read: port=%04x ret=%02x\n", port, ret);
return ret;
}
static void
ess_soundpiper_mca_write(const uint16_t port, const uint8_t val, void *priv)
{
sb_t *ess = (sb_t *) priv;
if (port < 0x102)
return;
sb_log("ess_soundpiper_mca_write: port=%04x val=%02x\n", port, val);
if (ess->dsp.sb_addr != 0x0000) {
io_removehandler(ess->dsp.sb_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(ess->dsp.sb_addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(ess->dsp.sb_addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(0x0388, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(0x0388, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&ess->dsp, 0);
gameport_remap(ess->gameport, 0);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688) {
mpu401_change_addr(ess->mpu, 0);
io_removehandler(0x0330, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
ess->pos_regs[port & 7] = val;
if (ess->pos_regs[2] & 1) {
switch (ess->pos_regs[2] & 0x0e) {
default:
ess->dsp.sb_addr = 0x0000;
break;
case 0x08:
ess->dsp.sb_addr = 0x0220;
break;
case 0x0c:
ess->dsp.sb_addr = 0x0240;
break;
}
if (ess->dsp.sb_addr != 0x0000) {
io_sethandler(ess->dsp.sb_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->dsp.sb_addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->dsp.sb_addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(0x0388, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL, ess->opl.priv);
io_sethandler(0x0388, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688) {
mpu401_change_addr(ess->mpu, ess->pos_regs[3] & 0x02 ? 0x0330 : 0);
if (ess->pos_regs[3] & 0x02)
io_sethandler(0x0330, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&ess->dsp, ess->dsp.sb_addr);
gameport_remap(ess->gameport, (ess->pos_regs[3] & 0x01) ? 0x200 : 0);
}
switch (ess->pos_regs[3] & 0xc0) {
default:
break;
case 0x80:
sb_dsp_setirq(&ess->dsp, 9);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688)
mpu401_setirq(ess->mpu, 9);
break;
case 0xa0:
sb_dsp_setirq(&ess->dsp, 5);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688)
mpu401_setirq(ess->mpu, 5);
break;
case 0xc0:
sb_dsp_setirq(&ess->dsp, 7);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688)
mpu401_setirq(ess->mpu, 7);
break;
case 0xe0:
sb_dsp_setirq(&ess->dsp, 10);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688)
mpu401_setirq(ess->mpu, 10);
break;
}
if (ess->pos_regs[3] & 0x04) {
sb_dsp_setdma8(&ess->dsp, ess->pos_regs[2] >> 4);
sb_dsp_setdma16_8(&ess->dsp, ess->pos_regs[2] >> 4);
}
}
static void
ess_chipchat_mca_write(const uint16_t port, uint8_t val, void *priv)
{
sb_t *ess = (sb_t *) priv;
if ((port < 0x102) || (port == 0x103))
return;
sb_log("ess_chipchat_mca_write: port=%04x val=%02x\n", port, val);
if (ess->dsp.sb_addr != 0x0000) {
io_removehandler(ess->dsp.sb_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(ess->dsp.sb_addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(ess->dsp.sb_addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(0x0388, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(0x0388, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(ess->dsp.sb_addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&ess->dsp, 0);
gameport_remap(ess->gameport, 0);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688) {
mpu401_change_addr(ess->mpu, 0);
io_removehandler(0x0330, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
ess->pos_regs[port & 7] = val;
if (ess->pos_regs[2] & 0x01) {
ess->dsp.sb_addr = 0x0220;
io_sethandler(ess->dsp.sb_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->dsp.sb_addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->dsp.sb_addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(0x0388, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL, ess->opl.priv);
io_sethandler(0x0388, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1688) {
mpu401_change_addr(ess->mpu, 0x0330);
io_sethandler(0x0330, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&ess->dsp, ess->dsp.sb_addr);
gameport_remap(ess->gameport, 0x0200);
sb_dsp_setirq(&ess->dsp, 7);
mpu401_setirq(ess->mpu, 7);
sb_dsp_setdma8(&ess->dsp, 1);
sb_dsp_setdma16_8(&ess->dsp, 1);
}
}
static uint16_t
ess_dac2_dmaread(void *priv, int channel)
{
sb_t *ess = (sb_t *) priv;
int ret;
if (channel >= 4) {
if (ess->ess_dac2_dmaff) {
uint32_t temp = (ess->ess_dac2_dmadat & 0xff00) >> 8;
temp |= (ess->ess_dac2_dmadat & 0xffff0000);
ret = (int) temp;
} else {
ess->ess_dac2_dmadat = dma_channel_read(channel);
if (ess->ess_dac2_dmadat == DMA_NODATA)
return DMA_NODATA;
ret = ess->ess_dac2_dmadat & 0xff;
}
ess->ess_dac2_dmaff = !ess->ess_dac2_dmaff;
} else
ret = dma_channel_read(channel);
return ret;
}
void
ess_dac2_update(void *priv)
{
sb_t *ess = (sb_t *) priv;
for (; ess->ess_dac2_pos < sound_pos_global; ess->ess_dac2_pos++) {
ess->ess_dac2_buffer[ess->ess_dac2_pos * 2] = *(int16_t *) &ess->ess_dac2_datl;
ess->ess_dac2_buffer[ess->ess_dac2_pos * 2 + 1] = *(int16_t *) &ess->ess_dac2_datr;
}
}
void
ess_dac2_poll(void *priv)
{
sb_t *ess = (sb_t *) priv;
int data[2];
int32_t temp;
timer_advance_u64(&ess->ess_dac2_timer, (uint64_t) ess->ess_dac2_latcho);
if (ess->ess_dac2_enable && !ess->ess_dac2_suspend) {
uint8_t format = ess->ess_dac2_signed ? 0x01 : 0;
format |= ess->ess_dac2_stereo ? 0x02 : 0;
format |= ess->ess_dac2_16bit ? 0x04 : 0;
ess_dac2_update(ess);
switch (format) {
default:
break;
case 0x00: /* Unsigned 8-bit mono */
data[0] = ess_dac2_dmaread(ess, ess->ess_dac2_dma);
if (data[0] == DMA_NODATA)
break;
data[0] = (int16_t) ((data[0] ^ 0x80) << 8);
ess->ess_dac2_datl = ess->ess_dac2_datr = data[0];
if ((ess->ess_dac2_dma <= 3) || ((ess->ess_dac2_dma >= 4) && !ess->ess_dac2_dmaff))
ess->ess_dac2_counter--;
break;
case 0x01: /* Signed 8-bit mono */
data[0] = ess_dac2_dmaread(ess, ess->ess_dac2_dma);
if (data[0] == DMA_NODATA)
break;
data[0] = (int16_t) (data[0] << 8);
ess->ess_dac2_datl = ess->ess_dac2_datr = data[0];
if ((ess->ess_dac2_dma <= 3) || ((ess->ess_dac2_dma >= 4) && !ess->ess_dac2_dmaff))
ess->ess_dac2_counter--;
break;
case 0x02: /* Unsigned 8-bit stereo */
data[0] = ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[1] = ess_dac2_dmaread(ess, ess->ess_dac2_dma);
if ((data[0] == DMA_NODATA) || (data[1] == DMA_NODATA))
break;
ess->ess_dac2_datl = (int16_t) ((data[0] ^ 0x80) << 8);
ess->ess_dac2_datr = (int16_t) ((data[1] ^ 0x80) << 8);
if (ess->ess_dac2_dma >= 4)
ess->ess_dac2_counter--;
else
ess->ess_dac2_counter -= 2;
break;
case 0x03: /* Signed 8-bit stereo */
data[0] = ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[1] = ess_dac2_dmaread(ess, ess->ess_dac2_dma);
if ((data[0] == DMA_NODATA) || (data[1] == DMA_NODATA))
break;
ess->ess_dac2_datl = (int16_t) (data[0] << 8);
ess->ess_dac2_datr = (int16_t) (data[1] << 8);
if (ess->ess_dac2_dma >= 4)
ess->ess_dac2_counter--;
else
ess->ess_dac2_counter -= 2;
break;
case 0x04: /* Unsigned 16-bit mono */
if (ess->ess_dac2_dma >= 4)
data[0] = dma_channel_read(ess->ess_dac2_dma);
else {
temp = (int32_t) ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[0] = (int16_t) ((ess_dac2_dmaread(ess, ess->ess_dac2_dma) << 8) | temp);
}
if (data[0] == DMA_NODATA)
break;
ess->ess_dac2_datl = ess->ess_dac2_datr = (int16_t) ((data[0] & 0xffff) ^ 0x8000);
if (ess->ess_dac2_dma >= 4)
ess->ess_dac2_counter--;
else
ess->ess_dac2_counter -= 2;
break;
case 0x05: /* Signed 16-bit mono */
if (ess->ess_dac2_dma >= 4)
data[0] = dma_channel_read(ess->ess_dac2_dma);
else {
temp = (int32_t) ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[0] = (int16_t) ((ess_dac2_dmaread(ess, ess->ess_dac2_dma) << 8) | temp);
}
if (data[0] == DMA_NODATA)
break;
ess->ess_dac2_datl = ess->ess_dac2_datr = (int16_t) (data[0] & 0xffff);
if (ess->ess_dac2_dma >= 4)
ess->ess_dac2_counter--;
else
ess->ess_dac2_counter -= 2;
break;
case 0x06: /* Unsigned 16-bit stereo */
if (ess->ess_dac2_dma >= 4) {
data[0] = dma_channel_read(ess->ess_dac2_dma);
data[1] = dma_channel_read(ess->ess_dac2_dma);
} else {
temp = (int32_t) ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[0] = (int16_t) ((ess_dac2_dmaread(ess, ess->ess_dac2_dma) << 8) | temp);
temp = (int32_t) ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[1] = (int16_t) ((ess_dac2_dmaread(ess, ess->ess_dac2_dma) << 8) | temp);
}
if ((data[0] == DMA_NODATA) || (data[1] == DMA_NODATA))
break;
ess->ess_dac2_datl = (int16_t) ((data[0] & 0xffff) ^ 0x8000);
ess->ess_dac2_datr = (int16_t) ((data[1] & 0xffff) ^ 0x8000);
if (ess->ess_dac2_dma >= 4)
ess->ess_dac2_counter -= 2;
else
ess->ess_dac2_counter -= 4;
break;
case 0x07: /* Signed 16-bit stereo */
if (ess->ess_dac2_dma >= 4) {
data[0] = dma_channel_read(ess->ess_dac2_dma);
data[1] = dma_channel_read(ess->ess_dac2_dma);
} else {
temp = (int32_t) ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[0] = (int16_t) ((ess_dac2_dmaread(ess, ess->ess_dac2_dma) << 8) | temp);
temp = (int32_t) ess_dac2_dmaread(ess, ess->ess_dac2_dma);
data[1] = (int16_t) ((ess_dac2_dmaread(ess, ess->ess_dac2_dma) << 8) | temp);
}
if ((data[0] == DMA_NODATA) || (data[1] == DMA_NODATA))
break;
ess->ess_dac2_datl = (int16_t) (data[0] & 0xffff);
ess->ess_dac2_datr = (int16_t) (data[1] & 0xffff);
if (ess->ess_dac2_dma >= 4)
ess->ess_dac2_counter -= 2;
else
ess->ess_dac2_counter -= 4;
break;
}
}
if (ess->ess_dac2_counter < 0) {
if (!ess->ess_dac2_autoinit) {
ess->ess_dac2_enable = 0;
ess->mixer_ess.regs[0x78] &= 0xfd;
timer_disable(&ess->ess_dac2_timer);
} else
ess->ess_dac2_counter = ess->ess_dac2_autolen;
if (ess->mixer_ess.regs[0x7a] & 0x40) {
if (!ess->ess_dac2_irq) /* Shared IRQ mode */
picint(1 << ess->dsp.sb_irqnum);
else
picint(1 << ess->ess_dac2_irq);
ess->mixer_ess.regs[0x7a] |= 0x80;
}
}
}
static void
es186x_pnp_write(uint16_t port, uint8_t val, void *priv)
{
sb_t *ess = (sb_t *) priv;
//sb_log("ES186x PnP config write: port = %04X, val = %02X\n", port, val);
if (port == 0x279) {
if (ess->es186x_bypass) {
switch (ess->es186x_bypass_state) {
case 0:
ess->es186x_confaddr = val;
ess->es186x_bypass_state = 1;
break;
case 1:
ess->es186x_confaddr = (val << 8) | ess->es186x_confaddr;
sb_log("ES186x PnP bypass, new control addr = %04X\n", ess->es186x_confaddr);
ess->es186x_bypass_conf->activate = 1;
ess->es186x_bypass_conf->io[0].base = ess->es186x_confaddr;
ess_186x_pnp_config_changed(0, ess->es186x_bypass_conf, ess);
ess->es186x_bypass_state = 0;
ess->es186x_bypass = 0;
break;
default:
break;
}
} else if (val == es186x_pnp_key[ess->es186x_key_pos]) {
ess->es186x_key_pos++;
if (!ess->es186x_key_pos) {
sb_log("ES186x bypass key used, config unlocked\n");
ess->es186x_bypass = 1;
}
}
}
}
void
ess_calc_input_gains(void)
{
int c = 0;
double attenuation;
for (c = 0; c < 16; c++) {
attenuation = -6.0;
if (c & 0x01)
attenuation += 1.5;
if (c & 0x02)
attenuation += 3.0;
if (c & 0x04)
attenuation += 6.0;
if (c & 0x08)
attenuation += 12.0;
attenuation = pow(10, attenuation / 10);
ess_input_gain_vols_4bits[c] = (int) (attenuation);
}
}
void *
sb_init(UNUSED(const device_t *info))
{
/* SB1.x port mappings, 210h to 260h in 10h steps:
(SB2 port mappings are 220h or 240h)
2x0 to 2x3 -> CMS chip
2x6, 2xA, 2xC, 2xE -> DSP chip
2x8, 2x9, 388 and 389 FM chip
SB2 "CD version" also uses 250h or 260h:
2x0 to 2x3 -> CDROM interface
2x4 to 2x5 -> Mixer interface */
/* My SB 2.0 mirrors the OPL2 at ports 2x0/2x1. Presumably this mirror is disabled when the
CMS chips are present.
This mirror may also exist on SB 1.5 & MCV, however I am unable to test this. It shouldn't
exist on SB 1.0 as the CMS chips are always present there. Syndicate requires this mirror
for music to play. */
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
const uint16_t addr = device_get_config_hex16("base");
uint8_t dspver = SB_DSP_105;
uint16_t mixer_addr = 0x0000;
switch (info->local) {
default:
case SB_1:
dspver = device_get_config_int("dspver");
sb->cms_enabled = 1;
break;
case SB_15:
dspver = device_get_config_int("dspver");
sb->cms_enabled = device_get_config_int("cms");
break;
case SB_2:
dspver = device_get_config_int("dspver");
sb->cms_enabled = device_get_config_int("cms");
mixer_addr = device_get_config_int("mixaddr");
break;
case THUNDERBOARD:
dspver = SB_DSP_200;
sb->cms_enabled = 0;
break;
}
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled)
fm_driver_get(FM_YM3812, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, dspver, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, 1); // SB 1, SB1.5 and 2 don't support DMA3
if (mixer_addr > 0x0000)
sb_ct1335_mixer_reset(sb);
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200;
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
if (sb->opl_enabled) {
// TODO: See if this applies to the SB1.5 as well
if ((!sb->cms_enabled) && ((dspver >= SB_DSP_200) && (dspver <= SB_DSP_202))) {
io_sethandler(addr, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
if (sb->cms_enabled) {
memset(&sb->cms, 0, sizeof(cms_t));
io_sethandler(addr, 0x0004,
cms_read, NULL, NULL,
cms_write, NULL, NULL,
&sb->cms);
}
if (mixer_addr > 0x0000) {
sb->mixer_enabled = 1;
io_sethandler(mixer_addr + 4, 0x0002,
sb_ct1335_mixer_read, NULL, NULL,
sb_ct1335_mixer_write, NULL, NULL,
sb);
} else
sb->mixer_enabled = 0;
sound_add_handler(sb_get_buffer_sb2, sb);
sound_add_handler(sb_get_cms_buffer_sb2, sb);
sound_in_add_handler(sb_put_buffer_sb, sb);
sound_in_start_input();
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sb2, sb);
sound_set_cd_audio_filter(sb2_filter_cd_audio, sb);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
return sb;
}
void *
thunderboard_init(UNUSED(const device_t *info))
{
/* ThunderBoard port mappings, 210h to 260h in 10h steps
2x6, 2xA, 2xC, 2xE -> DSP chip */
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
const uint16_t addr = device_get_config_hex16("base");
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled)
fm_driver_get(FM_YM3812, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 0);
sb_dsp_init(&sb->dsp, SB_DSP_200, SB_SUBTYPE_MVD201, sb);
/* DSP I/O handler is activated in sb_dsp_setaddr */
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, 1);
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_device);
sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
}
/* DSP I/O handler is activated in sb_dsp_setaddr */
if (sb->opl_enabled) {
io_sethandler(addr, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
sb->cms_enabled = 0;
sb->mixer_enabled = 0;
sound_add_handler(sb_get_buffer_sb2, sb);
sound_in_add_handler(sb_put_buffer_sb, sb);
sound_in_start_input();
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sb2, sb);
sound_set_cd_audio_filter(sb2_filter_cd_audio, sb);
return sb;
}
void *
sb_mcv_init(UNUSED(const device_t *info))
{
/* SB1/2 port mappings, 210h to 260h in 10h steps
2x6, 2xA, 2xC, 2xE -> DSP chip
2x8, 2x9, 388 and 389 FM chip */
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled)
fm_driver_get(FM_YM3812, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, SB_DSP_105, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setaddr(&sb->dsp, 0);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb->mixer_enabled = 0;
sound_add_handler(sb_get_buffer_sb2, sb);
sound_in_add_handler(sb_put_buffer_sb, sb);
sound_in_start_input();
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sb2, sb);
sound_set_cd_audio_filter(sb2_filter_cd_audio, sb);
/* I/O handlers activated in sb_mcv_write */
mca_add(sb_mcv_read, sb_mcv_write, sb_mcv_feedb, NULL, sb);
sb->pos_regs[0] = 0x84;
sb->pos_regs[1] = 0x50;
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200;
}
return sb;
}
static uint8_t
sb_pro_v1_opl_read(uint16_t port, void *priv)
{
sb_t *sb = (sb_t *) priv;
cycles -= ((int) (isa_timing * 8));
(void) sb->opl2.read(port, sb->opl2.priv); // read, but ignore
return (sb->opl.read(port, sb->opl.priv));
}
static void
sb_pro_v1_opl_write(uint16_t port, uint8_t val, void *priv)
{
sb_t *sb = (sb_t *) priv;
sb->opl.write(port, val, sb->opl.priv);
sb->opl2.write(port, val, sb->opl2.priv);
}
static void *
sb_pro_v1_init(UNUSED(const device_t *info))
{
/* SB Pro port mappings, 220h or 240h.
2x0 to 2x3 -> FM chip, Left and Right (9*2 voices)
2x4 to 2x5 -> Mixer interface
2x6, 2xA, 2xC, 2xE -> DSP chip
2x8, 2x9, 388 and 389 FM chip (9 voices)
2x0+10 to 2x0+13 CDROM interface. */
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
const uint16_t addr = device_get_config_hex16("base");
uint8_t dspver = device_get_config_int("dspver");
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled) {
fm_driver_get(FM_YM3812, &sb->opl);
sb->opl.set_do_cycles(sb->opl.priv, 0);
sb->has_dualopl2 = 1;
fm_driver_get(FM_YM3812, &sb->opl2);
sb->opl2.set_do_cycles(sb->opl2.priv, 0);
}
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, dspver, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_ct1345_mixer_reset(sb);
/* DSP I/O handler is activated in sb_dsp_setaddr */
if (sb->opl_enabled) {
io_sethandler(addr, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 2, 0x0002,
sb->opl2.read, NULL, NULL,
sb->opl2.write, NULL, NULL,
sb->opl2.priv);
io_sethandler(addr + 8, 0x0002,
sb_pro_v1_opl_read, NULL, NULL,
sb_pro_v1_opl_write, NULL, NULL,
sb);
io_sethandler(0x0388, 0x0002,
sb_pro_v1_opl_read, NULL, NULL,
sb_pro_v1_opl_write, NULL, NULL,
sb);
}
sb->mixer_enabled = 1;
io_sethandler(addr + 4, 0x0002,
sb_ct1345_mixer_read, NULL, NULL,
sb_ct1345_mixer_write, NULL, NULL,
sb);
sound_add_handler(sb_get_buffer_sbpro, sb);
sound_in_add_handler(sb_put_buffer_sbpro, sb);
sound_in_start_input();
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sbpro, sb);
sound_set_cd_audio_filter(sbpro_filter_cd_audio, sb);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200;
}
return sb;
}
static void *
sb_pro_v2_init(UNUSED(const device_t *info))
{
/* SB Pro 2 port mappings, 220h or 240h.
2x0 to 2x3 -> FM chip (18 voices)
2x4 to 2x5 -> Mixer interface
2x6, 2xA, 2xC, 2xE -> DSP chip
2x8, 2x9, 388 and 389 FM chip (9 voices)
2x0+10 to 2x0+13 CDROM interface. */
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
const uint16_t addr = device_get_config_hex16("base");
const uint8_t dspver = sb->opl_enabled = device_get_config_int("dspver");
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled)
fm_driver_get_cs(FM_YMF262, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, dspver, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_ct1345_mixer_reset(sb);
/* DSP I/O handler is activated in sb_dsp_setaddr */
if (sb->opl_enabled) {
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
sb->mixer_enabled = 1;
io_sethandler(addr + 4, 0x0002,
sb_ct1345_mixer_read, NULL, NULL,
sb_ct1345_mixer_write, NULL, NULL,
sb);
sound_add_handler(sb_get_buffer_sbpro, sb);
sound_in_add_handler(sb_put_buffer_sbpro, sb);
sound_in_start_input();
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sbpro, sb);
sound_set_cd_audio_filter(sbpro_filter_cd_audio, sb);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200;
}
return sb;
}
static void *
sb_pro_mcv_init(UNUSED(const device_t *info))
{
/* SB Pro MCV port mappings, 220h or 240h.
2x0 to 2x3 -> FM chip, Left and Right (18 voices)
2x4 to 2x5 -> Mixer interface
2x6, 2xA, 2xC, 2xE -> DSP chip
2x8, 2x9, 388 and 389 FM chip (9 voices) */
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
sb->opl_enabled = 1;
fm_driver_get_cs(FM_YMF262, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, SBPRO_DSP_302, SB_SUBTYPE_DEFAULT, sb);
sb_ct1345_mixer_reset(sb);
sb->mixer_enabled = 1;
sound_add_handler(sb_get_buffer_sbpro, sb);
sound_in_add_handler(sb_put_buffer_sbpro, sb);
sound_in_start_input();
music_add_handler(sb_get_music_buffer_sbpro, sb);
sound_set_cd_audio_filter(sbpro_filter_cd_audio, sb);
/* I/O handlers activated in sb_pro_mcv_write */
mca_add(sb_pro_mcv_read, sb_pro_mcv_write, sb_mcv_feedb, NULL, sb);
sb->pos_regs[0] = 0x03;
sb->pos_regs[1] = 0x51;
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200;
}
return sb;
}
static void *
sb_pro_compat_init(UNUSED(const device_t *info))
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
/*
Force Crystal counter behavior - following the typo
(255 instead of 256) in the English YM262 datasheet.
*/
fm_driver_get_cs(FM_YMF262, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, SBPRO_DSP_302, SB_SUBTYPE_DEFAULT, sb);
sb_ct1345_mixer_reset(sb);
sb->mixer_enabled = 1;
sound_add_handler(sb_get_buffer_sbpro, sb);
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sbpro, sb);
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, 0, 0, M_UART, 1);
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
return sb;
}
static void *
sb_16_init(UNUSED(const device_t *info))
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
const uint16_t addr = device_get_config_hex16("base");
const uint16_t mpu_addr = device_get_config_hex16("base401");
const uint8_t dspver = device_get_config_int("dspver");
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled)
fm_driver_get_cs((int) (intptr_t) info->local, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, (info->local == FM_YMF289B) ? SBAWE32_DSP_413 : dspver, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_setdma16(&sb->dsp, device_get_config_int("dma16"));
sb_dsp_setdma16_supported(&sb->dsp, 1);
sb_dsp_setdma16_enabled(&sb->dsp, 1);
sb_ct1745_mixer_reset(sb);
if (sb->opl_enabled) {
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
sb->mixer_enabled = 1;
sb->mixer_sb16.output_filter = 1;
io_sethandler(addr + 4, 0x0002, sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL, sb);
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
sound_in_add_handler(sb_put_buffer_sb16_awe32, sb);
sound_in_start_input();
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
sound_set_cd_audio_filter(sb16_awe32_filter_cd_audio, sb);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(sb16_awe32_filter_pc_speaker, sb);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(sb16_awe32_filter_midi, sb);
if (mpu_addr) {
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, device_get_config_hex16("base401"), 0, M_UART,
device_get_config_int("receive_input401"));
} else
sb->mpu = NULL;
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
if (info->local == FM_YMF289B) {
sb->gameport = gameport_add(&gameport_pnp_device);
sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
} else {
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200;
}
}
return sb;
}
static void *
sb_16_reply_mca_init(UNUSED(const device_t *info))
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
sb->opl_enabled = 1;
fm_driver_get_cs(FM_YMF262, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, SB16_DSP_405, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setdma16_supported(&sb->dsp, 1);
sb_dsp_setdma16_enabled(&sb->dsp, 1);
sb_ct1745_mixer_reset(sb);
sb->mixer_enabled = 1;
sb->mixer_sb16.output_filter = 1;
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
sound_in_add_handler(sb_put_buffer_sb16_awe32, sb);
sound_in_start_input();
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
sound_set_cd_audio_filter(sb16_awe32_filter_cd_audio, sb);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(sb16_awe32_filter_pc_speaker, sb);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(sb16_awe32_filter_midi, sb);
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, 0, 0, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
sb->gameport = gameport_add(&gameport_200_device);
/* I/O handlers activated in sb_pro_mcv_write */
mca_add(sb_16_reply_mca_read, sb_16_reply_mca_write, sb_mcv_feedb, NULL, sb);
sb->pos_regs[0] = 0x38;
sb->pos_regs[1] = 0x51;
sb->gameport_addr = 0x200;
return sb;
}
static int
sb_16_pnp_noide_available(void)
{
return rom_present(PNP_ROM_SB_16_PNP_NOIDE);
}
static int
sb_16_pnp_ide_available(void)
{
return rom_present(PNP_ROM_SB_16_PNP_IDE);
}
static void *
sb_16_pnp_init(UNUSED(const device_t *info))
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
const uint8_t dspver = device_get_config_int("dspver");
sb->pnp = 1;
sb->opl_enabled = 1;
fm_driver_get_cs((int) (intptr_t) FM_CQM, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, dspver, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setdma16_supported(&sb->dsp, 1);
sb_ct1745_mixer_reset(sb);
sb->mixer_enabled = 1;
sb->mixer_sb16.output_filter = 1;
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
sound_in_add_handler(sb_put_buffer_sb16_awe32, sb);
sound_in_start_input();
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
sound_set_cd_audio_filter(sb16_awe32_filter_cd_audio, sb);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(sb16_awe32_filter_pc_speaker, sb);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(sb16_awe32_filter_midi, sb);
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, 0, 0, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
sb->gameport = gameport_add(&gameport_pnp_device);
// Does it have IDE?
if (info->local != SB_16_PNP_NOIDE) {
device_add(&ide_qua_pnp_device);
other_ide_present++;
sb->has_ide = 1;
}
const char *pnp_rom_file = NULL;
uint16_t pnp_rom_len = 512;
switch (info->local) {
case SB_16_PNP_NOIDE:
pnp_rom_file = PNP_ROM_SB_16_PNP_NOIDE;
break;
case SB_16_PNP_IDE:
pnp_rom_file = PNP_ROM_SB_16_PNP_IDE;
break;
default:
break;
}
uint8_t *pnp_rom = NULL;
if (pnp_rom_file) {
FILE *fp = rom_fopen(pnp_rom_file, "rb");
if (fp) {
if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len)
pnp_rom = sb->pnp_rom;
fclose(fp);
}
}
isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_16_pnp_config_changed,
NULL, NULL, NULL, sb);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_setaddr(&sb->dsp, 0);
sb_dsp_setirq(&sb->dsp, 0);
sb_dsp_setdma8(&sb->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED);
mpu401_change_addr(sb->mpu, 0);
if (info->local != SB_16_PNP_NOIDE)
ide_remove_handlers(3);
sb->gameport_addr = 0;
gameport_remap(sb->gameport, 0);
return sb;
}
static int
sb_vibra16c_available(void)
{
return rom_present(PNP_ROM_SB_VIBRA16C);
}
static int
sb_vibra16cl_available(void)
{
return rom_present(PNP_ROM_SB_VIBRA16CL);
}
static int
sb_vibra16xv_available(void)
{
return rom_present(PNP_ROM_SB_VIBRA16XV);
}
static void *
sb_vibra16_pnp_init(UNUSED(const device_t *info))
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
sb->pnp = 1;
sb->opl_enabled = 1;
fm_driver_get_cs(FM_CQM, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, (info->local == SB_VIBRA16XV) ? SBAWE64_DSP_416 : SBAWE32_DSP_413, SB_SUBTYPE_DEFAULT, sb);
/* The ViBRA 16XV does 16-bit DMA through 8-bit DMA. */
sb_dsp_setdma16_supported(&sb->dsp, info->local != SB_VIBRA16XV);
sb_ct1745_mixer_reset(sb);
sb->mixer_enabled = 1;
sb->mixer_sb16.output_filter = 1;
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
sound_in_add_handler(sb_put_buffer_sb16_awe32, sb);
sound_in_start_input();
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
sound_set_cd_audio_filter(sb16_awe32_filter_cd_audio, sb);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(sb16_awe32_filter_pc_speaker, sb);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(sb16_awe32_filter_midi, sb);
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, 0, 0, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
switch (info->local) {
case SB_VIBRA16C: /* CTL7001 */
case SB_VIBRA16CL: /* CTL7002 */
sb->gameport = gameport_add(&gameport_pnp_device);
break;
case SB_VIBRA16XV: /* CTL7005 */
sb->gameport = gameport_add(&gameport_pnp_1io_device);
break;
default:
break;
}
const char *pnp_rom_file = NULL;
switch (info->local) {
case SB_VIBRA16C:
pnp_rom_file = PNP_ROM_SB_VIBRA16C;
break;
case SB_VIBRA16CL:
pnp_rom_file = PNP_ROM_SB_VIBRA16CL;
break;
case SB_VIBRA16XV:
pnp_rom_file = PNP_ROM_SB_VIBRA16XV;
break;
default:
break;
}
uint8_t *pnp_rom = NULL;
if (pnp_rom_file) {
FILE *fp = rom_fopen(pnp_rom_file, "rb");
uint16_t pnp_rom_len = 512;
if (fp) {
if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len)
pnp_rom = sb->pnp_rom;
fclose(fp);
}
}
switch (info->local) {
case SB_VIBRA16C:
case SB_VIBRA16CL:
case SB_VIBRA16XV:
isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_vibra16_pnp_config_changed,
NULL, NULL, NULL, sb);
break;
default:
break;
}
sb_dsp_setaddr(&sb->dsp, 0);
sb_dsp_setirq(&sb->dsp, 0);
sb_dsp_setdma8(&sb->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED);
mpu401_change_addr(sb->mpu, 0);
sb->gameport_addr = 0;
gameport_remap(sb->gameport, 0);
return sb;
}
static void *
sb_16_compat_init(const device_t *info)
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
fm_driver_get_cs(FM_YMF262, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, SB16_DSP_405, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setdma16_supported(&sb->dsp, 1);
sb_dsp_setdma16_enabled(&sb->dsp, 1);
sb_ct1745_mixer_reset(sb);
sb->opl_enabled = 1;
sb->mixer_enabled = 1;
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
sound_in_add_handler(sb_put_buffer_sb16_awe32, sb);
sound_in_start_input();
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, 0, 0, M_UART, (int) (intptr_t) info->local);
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
sb->gameport = gameport_add(&gameport_pnp_device);
sb->gameport_addr = 0x200;
gameport_remap(sb->gameport, sb->gameport_addr);
return sb;
}
static int
sb_awe32_available(void)
{
return rom_present(EMU8K_ROM_PATH);
}
static int
sb_goldfinch_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_GOLDFINCH);
}
static int
sb_32_pnp_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_32_PNP);
}
static int
sb_awe32_pnp_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE32_PNP);
}
static int
sb_awe32_ide_pnp_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE32_IDE_PNP);
}
static int
sb_awe64_value_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_VALUE);
}
static int
sb_awe64_noide_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_NOIDE);
}
static int
sb_awe64_ide_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_IDE);
}
static int
sb_awe64_gold_available(void)
{
return sb_awe32_available() && rom_present(PNP_ROM_SB_AWE64_GOLD);
}
static void *
sb_awe32_init(UNUSED(const device_t *info))
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
uint16_t addr = device_get_config_hex16("base");
uint16_t mpu_addr = device_get_config_hex16("base401");
uint16_t emu_addr = device_get_config_hex16("emu_base");
int onboard_ram = device_get_config_int("onboard_ram");
const uint8_t dspver = device_get_config_int("dspver");
sb->opl_enabled = device_get_config_int("opl");
if (sb->opl_enabled)
fm_driver_get_cs(FM_YMF262, &sb->opl);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb_dsp_init(&sb->dsp, dspver, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_setdma16(&sb->dsp, device_get_config_int("dma16"));
sb_dsp_setdma16_supported(&sb->dsp, 1);
sb_dsp_setdma16_enabled(&sb->dsp, 1);
sb_ct1745_mixer_reset(sb);
if (sb->opl_enabled) {
io_sethandler(addr, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(addr + 8, 0x0002,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
io_sethandler(0x0388, 0x0004,
sb->opl.read, NULL, NULL,
sb->opl.write, NULL, NULL,
sb->opl.priv);
}
sb->mixer_enabled = 1;
sb->mixer_sb16.output_filter = 1;
io_sethandler(addr + 4, 0x0002, sb_ct1745_mixer_read, NULL, NULL,
sb_ct1745_mixer_write, NULL, NULL, sb);
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
sound_in_add_handler(sb_put_buffer_sb16_awe32, sb);
sound_in_start_input();
if (sb->opl_enabled)
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
wavetable_add_handler(sb_get_wavetable_buffer_sb16_awe32, sb);
sound_set_cd_audio_filter(sb16_awe32_filter_cd_audio, sb);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(sb16_awe32_filter_pc_speaker, sb);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(sb16_awe32_filter_midi, sb);
if (mpu_addr) {
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, device_get_config_hex16("base401"), 0, M_UART,
device_get_config_int("receive_input401"));
} else
sb->mpu = NULL;
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
emu8k_init(&sb->emu8k, emu_addr, onboard_ram);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
if (device_get_config_int("gameport")) {
sb->gameport = gameport_add(&gameport_200_device);
sb->gameport_addr = 0x200;
}
return sb;
}
static void *
sb_goldfinch_init(const device_t *info)
{
goldfinch_t *goldfinch = (goldfinch_t *) calloc(1, sizeof(goldfinch_t));
int onboard_ram = device_get_config_int("onboard_ram");
wavetable_add_handler(sb_get_wavetable_buffer_goldfinch, goldfinch);
emu8k_init(&goldfinch->emu8k, 0, onboard_ram);
const char *pnp_rom_file = NULL;
switch (info->local) {
case 0:
pnp_rom_file = PNP_ROM_SB_GOLDFINCH;
break;
default:
break;
}
uint8_t *pnp_rom = NULL;
if (pnp_rom_file) {
FILE *fp = rom_fopen(pnp_rom_file, "rb");
uint16_t pnp_rom_len = 256;
if (fp) {
if (fread(goldfinch->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len)
pnp_rom = goldfinch->pnp_rom;
fclose(fp);
}
}
switch (info->local) {
case 0:
isapnp_add_card(pnp_rom, sizeof(goldfinch->pnp_rom), goldfinch_pnp_config_changed,
NULL, NULL, NULL, goldfinch);
break;
default:
break;
}
emu8k_change_addr(&goldfinch->emu8k, 0);
return goldfinch;
}
static void *
sb_awe32_pnp_init(const device_t *info)
{
sb_t *sb = (sb_t *) calloc(1, sizeof(sb_t));
int onboard_ram = device_get_config_int("onboard_ram");
int cqm = (info->local != SB_AWE32_PNP);
sb->pnp = 1;
sb->opl_enabled = 1;
fm_driver_get_cs(cqm ? FM_CQM : FM_YMF262, &sb->opl);
sb_dsp_init(&sb->dsp, (info->local >= SB_AWE64_VALUE) ?
SBAWE64_DSP_416 : SBAWE32_DSP_413, SB_SUBTYPE_DEFAULT, sb);
sb_dsp_setdma16_supported(&sb->dsp, 1);
sb_ct1745_mixer_reset(sb);
sb_dsp_set_real_opl(&sb->dsp, 1);
sb->mixer_enabled = 1;
sb->mixer_sb16.output_filter = 1;
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
sound_in_add_handler(sb_put_buffer_sb16_awe32, sb);
sound_in_start_input();
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
wavetable_add_handler(sb_get_wavetable_buffer_sb16_awe32, sb);
sound_set_cd_audio_filter(sb16_awe32_filter_cd_audio, sb);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(sb16_awe32_filter_pc_speaker, sb);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(sb16_awe32_filter_midi, sb);
sb->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(sb->mpu, 0, 0, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&sb->dsp, sb->mpu);
emu8k_init(&sb->emu8k, 0, onboard_ram);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &sb->dsp);
sb->gameport = gameport_add(&gameport_pnp_device);
// Does it have IDE?
if ((info->local != SB_AWE64_VALUE) && (info->local != SB_AWE64_NOIDE) && (info->local != SB_AWE64_GOLD)) {
device_add(&ide_qua_pnp_device);
other_ide_present++;
sb->has_ide = 1;
}
const char *pnp_rom_file = NULL;
switch (info->local) {
case SB_32_PNP:
pnp_rom_file = PNP_ROM_SB_32_PNP;
break;
case SB_AWE32_PNP:
pnp_rom_file = PNP_ROM_SB_AWE32_PNP;
break;
case SB_AWE32_IDE_PNP:
pnp_rom_file = PNP_ROM_SB_AWE32_IDE_PNP;
break;
case SB_AWE64_VALUE:
pnp_rom_file = PNP_ROM_SB_AWE64_VALUE;
break;
case SB_AWE64_NOIDE:
pnp_rom_file = PNP_ROM_SB_AWE64_NOIDE;
break;
case SB_AWE64_IDE:
pnp_rom_file = PNP_ROM_SB_AWE64_IDE;
break;
case SB_AWE64_GOLD:
pnp_rom_file = PNP_ROM_SB_AWE64_GOLD;
break;
default:
break;
}
uint8_t *pnp_rom = NULL;
if (pnp_rom_file) {
FILE *fp = rom_fopen(pnp_rom_file, "rb");
uint16_t pnp_rom_len = 512;
if (fp) {
if (fread(sb->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len)
pnp_rom = sb->pnp_rom;
fclose(fp);
}
}
switch (info->local) {
case SB_32_PNP:
case SB_AWE32_IDE_PNP:
isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_16_pnp_config_changed,
NULL, NULL, NULL, sb);
break;
case SB_AWE32_PNP:
isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe32_pnp_config_changed,
NULL, NULL, NULL, sb);
break;
case SB_AWE64_IDE:
isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_ide_config_changed,
NULL, NULL, NULL, sb);
break;
case SB_AWE64_VALUE:
case SB_AWE64_NOIDE:
case SB_AWE64_GOLD:
isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_pnp_noide_config_changed,
NULL, NULL, NULL, sb);
break;
default:
break;
}
sb_dsp_setaddr(&sb->dsp, 0);
sb_dsp_setirq(&sb->dsp, 0);
sb_dsp_setdma8(&sb->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16(&sb->dsp, ISAPNP_DMA_DISABLED);
mpu401_change_addr(sb->mpu, 0);
if ((info->local != SB_AWE64_VALUE) && (info->local != SB_AWE64_NOIDE) && (info->local != SB_AWE64_GOLD))
ide_remove_handlers(3);
emu8k_change_addr(&sb->emu8k, 0);
sb->gameport_addr = 0;
gameport_remap(sb->gameport, 0);
return sb;
}
static void *
ess_x488_init(UNUSED(const device_t *info))
{
sb_t *ess = (sb_t *) calloc(sizeof(sb_t), 1);
const uint16_t addr = device_get_config_hex16("base");
fm_driver_get(FM_YM3812, &ess->opl);
sb_dsp_set_real_opl(&ess->dsp, 1);
sb_dsp_init(&ess->dsp, SB_DSP_201, info->local ? SB_SUBTYPE_ESS_ES1488 : SB_SUBTYPE_ESS_ES488, ess);
sb_dsp_setaddr(&ess->dsp, addr);
sb_dsp_setirq(&ess->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&ess->dsp, device_get_config_int("dma"));
sb_dsp_setdma16_8(&ess->dsp, device_get_config_int("dma"));
sb_dsp_setdma16_supported(&ess->dsp, 0);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1488)
ess_mixer_reset(ess);
/* DSP I/O handler is activated in sb_dsp_setaddr */
io_sethandler(addr, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(0x0388, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(0x0388, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1488) {
ess->mixer_enabled = 1;
ess->mixer_ess.regs[0x40] = 0x0a;
io_sethandler(addr + 2, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
sound_add_handler(sb_get_buffer_ess, ess);
music_add_handler(sb_get_music_buffer_ess, ess);
sound_set_cd_audio_filter(ess_filter_cd_audio, ess);
} else {
sound_add_handler(sb_get_buffer_ess488, ess);
music_add_handler(sb_get_music_buffer_ess488, ess);
}
sound_in_add_handler(ess_put_buffer_esx488, ess);
sound_in_start_input();
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &ess->dsp);
if (device_get_config_int("gameport")) {
ess->gameport = gameport_add(&gameport_200_device);
ess->gameport_addr = 0x200;
}
int c = 0;
double attenuation;
for (c = 0; c < 16; c++) {
attenuation = -6.0;
if (c & 0x01)
attenuation += 1.5;
if (c & 0x02)
attenuation += 3.0;
if (c & 0x04)
attenuation += 6.0;
if (c & 0x08)
attenuation += 12.0;
attenuation = pow(10, attenuation / 10);
ess_input_gain_vols_4bits[c] = (int) (attenuation);
}
return ess;
}
/* The IDE port is there only with an address given for it. */
static uint32_t
ess_x688_ide_boards(UNUSED(const device_t *dev))
{
return ((device_get_config_int("ide_ctrl") & 0x0fff) > 0x0000) ? (1 << 3) : 0;
}
static void *
ess_x688_init(UNUSED(const device_t *info))
{
sb_t *ess = (sb_t *) calloc(sizeof(sb_t), 1);
const uint16_t addr = device_get_config_hex16("base");
const uint16_t ide_ctrl = (const uint16_t) device_get_config_int("ide_ctrl");
const uint16_t ide_base = ide_ctrl & 0x0fff;
const uint16_t ide_side = ide_base + 0x0206;
const uint16_t ide_irq = ide_ctrl >> 12;
fm_driver_get_cs(info->local ? FM_ESFM : FM_YMF262, &ess->opl);
sb_dsp_set_real_opl(&ess->dsp, 1);
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, info->local ? SB_SUBTYPE_ESS_ES1688 : SB_SUBTYPE_ESS_ES688, ess);
sb_dsp_setaddr(&ess->dsp, addr);
sb_dsp_setirq(&ess->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&ess->dsp, device_get_config_int("dma"));
sb_dsp_setdma16_8(&ess->dsp, device_get_config_int("dma"));
sb_dsp_setdma16_supported(&ess->dsp, 0);
ess_mixer_reset(ess);
if (device_get_config_int("dspver") == 1)
ess->dsp.ess_dsp_v2_mode = 1;
/* Filters are always enabled on ES688/1688. */
ess->mixer_ess.input_filter = 1;
ess->mixer_ess.output_filter = 1;
/* DSP I/O handler is activated in sb_dsp_setaddr */
io_sethandler(addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(0x0388, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(0x0388, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_sethandler(addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
ess->mixer_enabled = 1;
ess->mixer_ess.regs[0x40] = 0x02;
io_sethandler(addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
sound_add_handler(sb_get_buffer_ess, ess);
music_add_handler(sb_get_music_buffer_ess, ess);
sound_in_add_handler(ess_put_buffer, ess);
sound_in_start_input();
sound_set_cd_audio_filter(ess_filter_cd_audio, ess);
if (info->local && device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(ess_filter_pc_speaker, ess);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(ess_filter_midi, ess);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &ess->dsp);
if (info->local) {
ess->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
/* NOTE: The MPU is initialized disabled and with no IRQ assigned.
* It will be later initialized by the guest OS's drivers. */
mpu401_init(ess->mpu, 0, -1, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&ess->dsp, ess->mpu);
}
if (device_get_config_int("gameport")) {
ess->gameport = gameport_add(&gameport_200_device);
ess->gameport_addr = 0x200;
}
if (ide_base > 0x0000) {
device_add(&ide_qua_pnp_device);
ide_set_base(3, ide_base);
ide_set_side(3, ide_side);
ide_set_irq(3, ide_irq);
other_ide_present++;
ess->has_ide = 1;
}
int c = 0;
double attenuation;
for (c = 0; c < 16; c++) {
attenuation = -6.0;
if (c & 0x01)
attenuation += 1.5;
if (c & 0x02)
attenuation += 3.0;
if (c & 0x04)
attenuation += 6.0;
if (c & 0x08)
attenuation += 12.0;
attenuation = pow(10, attenuation / 10);
ess_input_gain_vols_4bits[c] = (int) (attenuation);
}
return ess;
}
static int
ess_688_pnp_available(void)
{
return rom_present(PNP_ROM_ESS0100);
}
static int
ess_1688_pnp_available(void)
{
return rom_present(PNP_ROM_ESS0102);
}
static int
ess_1688_968_pnp_available(void)
{
return rom_present(PNP_ROM_ESS0968);
}
static void *
ess_x688_pnp_init(UNUSED(const device_t *info))
{
sb_t *ess = (sb_t *) calloc(sizeof(sb_t), 1);
if (info->local == 3)
ess->pnp = 3;
else
ess->pnp = 1 + (int) info->local;
fm_driver_get_cs(info->local ? FM_ESFM : FM_YMF262, &ess->opl);
sb_dsp_set_real_opl(&ess->dsp, 1);
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, (info->local & 1) ? SB_SUBTYPE_ESS_ES1688 : SB_SUBTYPE_ESS_ES688, ess);
sb_dsp_setdma16_supported(&ess->dsp, 0);
ess_mixer_reset(ess);
/* Filters are always enabled on ES688/1688. */
ess->mixer_ess.input_filter = 1;
ess->mixer_ess.output_filter = 1;
ess->mixer_enabled = 1;
sound_add_handler(sb_get_buffer_ess, ess);
music_add_handler(sb_get_music_buffer_ess, ess);
sound_in_add_handler(ess_put_buffer, ess);
sound_in_start_input();
sound_set_cd_audio_filter(ess_filter_cd_audio, ess);
if ((info->local & 1) && device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(ess_filter_pc_speaker, ess);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(ess_filter_midi, ess);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &ess->dsp);
ess->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
/* NOTE: The MPU is initialized disabled and with no IRQ assigned.
* It will be later initialized by the guest OS's drivers. */
mpu401_init(ess->mpu, 0, -1, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&ess->dsp, ess->mpu);
ess->gameport = gameport_add(&gameport_pnp_device);
device_add(&ide_qua_pnp_device);
other_ide_present++;
ess->has_ide = 1;
const char *pnp_rom_file = NULL;
uint16_t pnp_rom_len = 512;
switch (info->local) {
case 0:
pnp_rom_file = PNP_ROM_ESS0100;
pnp_rom_len = 145;
break;
case 1:
pnp_rom_file = PNP_ROM_ESS0102;
pnp_rom_len = 145;
break;
case 2:
case 3:
pnp_rom_file = PNP_ROM_ESS0968;
pnp_rom_len = 127;
break;
default:
break;
}
uint8_t *pnp_rom = NULL;
if (pnp_rom_file) {
FILE *fp = rom_fopen(pnp_rom_file, "rb");
if (fp) {
if (fread(ess->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len)
pnp_rom = ess->pnp_rom;
fclose(fp);
}
}
isapnp_add_card(pnp_rom, sizeof(ess->pnp_rom), ess_x688_pnp_config_changed,
NULL, NULL, NULL, ess);
sb_dsp_setaddr(&ess->dsp, 0);
sb_dsp_setirq(&ess->dsp, 0);
sb_dsp_setdma8(&ess->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_8(&ess->dsp, ISAPNP_DMA_DISABLED);
mpu401_change_addr(ess->mpu, 0);
ess->gameport_addr = 0;
gameport_remap(ess->gameport, 0);
ide_remove_handlers(3);
int c = 0;
double attenuation;
for (c = 0; c < 16; c++) {
attenuation = -6.0;
if (c & 0x01)
attenuation += 1.5;
if (c & 0x02)
attenuation += 3.0;
if (c & 0x04)
attenuation += 6.0;
if (c & 0x08)
attenuation += 12.0;
attenuation = pow(10, attenuation / 10);
ess_input_gain_vols_4bits[c] = (int) (attenuation);
}
return ess;
}
static void *
ess_x688_mca_init(UNUSED(const device_t *info))
{
sb_t *ess = (sb_t *) calloc(1, sizeof(sb_t));
ess->opl_enabled = 1;
fm_driver_get_cs(info->local ? FM_ESFM : FM_YMF262, &ess->opl);
sb_dsp_set_real_opl(&ess->dsp, 1);
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, info->local ? SB_SUBTYPE_ESS_ES1688 : SB_SUBTYPE_ESS_ES688, ess);
sb_dsp_setdma16_supported(&ess->dsp, 0);
ess_mixer_reset(ess);
/* Filters are always enabled on ES688/1688. */
ess->mixer_ess.input_filter = 1;
ess->mixer_ess.output_filter = 1;
ess->mixer_enabled = 1;
sound_add_handler(sb_get_buffer_ess, ess);
music_add_handler(sb_get_music_buffer_ess, ess);
sound_in_add_handler(ess_put_buffer, ess);
sound_in_start_input();
sound_set_cd_audio_filter(ess_filter_cd_audio, ess);
if (info->local && device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(ess_filter_pc_speaker, ess);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(ess_filter_midi, ess);
if (info->local) {
ess->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(ess->mpu, 0, -1, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&ess->dsp, ess->mpu);
}
ess->gameport = gameport_add(&gameport_200_device);
mpu401_change_addr(ess->mpu, 0);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &ess->dsp);
ess->gameport_addr = 0;
gameport_remap(ess->gameport, 0);
/* I/O handlers activated in sb_pro_mcv_write */
if (info->local == 2) {
mca_add(ess_x688_mca_read, ess_chipchat_mca_write, sb_mcv_feedb, NULL, ess);
ess->pos_regs[0] = 0x50;
ess->pos_regs[1] = 0x51;
ess->pos_regs[3] = 0x50;
ess->dsp.is_chipchat = 1;
} else {
mca_add(ess_x688_mca_read, ess_soundpiper_mca_write, sb_mcv_feedb, NULL, ess);
ess->pos_regs[0] = 0x30;
ess->pos_regs[1] = 0x51;
}
int c = 0;
double attenuation;
for (c = 0; c < 16; c++) {
attenuation = -6.0;
if (c & 0x01)
attenuation += 1.5;
if (c & 0x02)
attenuation += 3.0;
if (c & 0x04)
attenuation += 6.0;
if (c & 0x08)
attenuation += 12.0;
attenuation = pow(10, attenuation / 10);
ess_input_gain_vols_4bits[c] = (int) (attenuation);
}
return ess;
}
static void *
ess_1x88_onboard_init(const device_t *info)
{
sb_t *ess = (sb_t *) calloc(sizeof(sb_t), 1);
uint8_t type = (info->local & 0x0f);
uint8_t is_compaq = (info->local >> 4);
fm_driver_get_cs(FM_ESFM, &ess->opl);
sb_dsp_set_real_opl(&ess->dsp, 1);
ess->opl_pnp_addr = 0x388;
switch (type) {
default:
break;
case 0: /* ES1688 */
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, SB_SUBTYPE_ESS_ES1688, ess);
ess->es1688_rsk_enable = 1;
break;
case 1: /* ES1788 */
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, SB_SUBTYPE_ESS_ES1788, ess);
break;
case 2: /* ES1888 */
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, SB_SUBTYPE_ESS_ES1888, ess);
break;
case 3: /* ES1887 */
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, SB_SUBTYPE_ESS_ES1887, ess);
break;
}
sb_dsp_setaddr(&ess->dsp, 0);
sb_dsp_setirq(&ess->dsp, 0);
sb_dsp_setdma8(&ess->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_8(&ess->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_supported(&ess->dsp, 0);
ess_mixer_reset(ess);
/* Filters are always enabled on ES1688 and higher */
ess->mixer_ess.input_filter = 1;
ess->mixer_ess.output_filter = 1;
/* DSP I/O handler is activated in sb_dsp_setaddr */
/* ES1788/1888/1887 starts in a disabled state */
ess->mixer_enabled = 1;
ess->mixer_ess.regs[0x40] = 0x02;
sound_add_handler(sb_get_buffer_ess, ess);
music_add_handler(sb_get_music_buffer_ess, ess);
sound_in_add_handler(ess_put_buffer, ess);
sound_in_start_input();
sound_set_cd_audio_filter(ess_filter_cd_audio, ess);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(ess_filter_pc_speaker, ess);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &ess->dsp);
ess->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
/* NOTE: The MPU is initialized disabled and with no IRQ assigned.
* It will be later initialized by the guest OS's drivers. */
mpu401_init(ess->mpu, 0, -1, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&ess->dsp, ess->mpu);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(ess_filter_midi, ess);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1887) {
ess->gameport = gameport_add(&gameport_pnp_device);
ess->gameport_addr = 0x200;
gameport_remap(ess->gameport, ess->gameport_addr);
} else {
ess->gameport = gameport_add(&gameport_200_device);
ess->gameport_addr = 0x200;
}
/* ES1688/1788/188x System Configuration Register ports */
io_sethandler(0xe0, 0x0002, NULL, NULL, NULL, ess_scr_write, NULL, NULL, ess);
io_sethandler(0xf9, 0x0001, NULL, NULL, NULL, ess_scr_write, NULL, NULL, ess);
io_sethandler(0xfb, 0x0001, NULL, NULL, NULL, ess_scr_write, NULL, NULL, ess);
ess->ess_scr_locked = 1;
/* ES1688/1788/188x Read-Sequence-Key mode */
ess->ess_readseq_state = 0;
ess->ess_dsp_addr = 0;
io_sethandler(0x220, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x229, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x22b, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x22d, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x22f, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x230, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x240, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x250, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1887) {
io_sethandler(0x200, 0x0004, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x388, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x398, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x3a8, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
io_sethandler(0x3b8, 0x0001, ess_rsk_read, NULL, NULL, NULL, NULL, NULL, ess);
}
/* ES188x secondary DAC */
if (ess->dsp.sb_subtype >= SB_SUBTYPE_ESS_ES1888) {
sound_add_handler(sb_get_buffer_ess_dac2, ess);
timer_add(&ess->ess_dac2_timer, ess_dac2_poll, ess, 0);
if ((is_compaq) || (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1887)) { /* 1887 and Compaq 1888 */
ess->ess_dac2_irq = 0; /* Use shared IRQ */
ess->ess_dac2_dma = 5;
} else { /* Non-Compaq 1888 */
ess->ess_dac2_irq = 11;
ess->ess_dac2_dma = 5;
}
ess->dsp.es188x_irq_mode = 0;
/* Initialize ESS filter to 8 kHz. This will be recalculated when a set frequency command is
sent. */
recalc_ess_dac2_filter(8000 * 2);
ess->mixer_ess.output_filter_dac2 = 1;
}
/* Calculate 6-bit attenuation values for ES1788+ master volume control */
uint8_t c;
double attenuation;
for (c = 0; c < 64; c++) {
attenuation = -47.25;
if (c & 0x01)
attenuation += 0.75;
if (c & 0x02)
attenuation += 1.5;
if (c & 0x04)
attenuation += 3.0;
if (c & 0x08)
attenuation += 6.0;
if (c & 0x10)
attenuation += 12.0;
if (c & 0x20)
attenuation += 24.0;
attenuation = pow(10, attenuation / 10);
ess_att_6bits[c] = (attenuation * 65536);
}
for (c = 0; c < 16; c++) {
attenuation = -6.0;
if (c & 0x01)
attenuation += 1.5;
if (c & 0x02)
attenuation += 3.0;
if (c & 0x04)
attenuation += 6.0;
if (c & 0x08)
attenuation += 12.0;
attenuation = pow(10, attenuation / 10);
ess_input_gain_vols_4bits[c] = (int) (attenuation);
}
return ess;
}
static void *
ess_186x_init(const device_t *info)
{
sb_t *ess = (sb_t *) calloc(sizeof(sb_t), 1);
fm_driver_get_cs(FM_ESFM, &ess->opl);
sb_dsp_set_real_opl(&ess->dsp, 1);
if (info->local & 1)
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, SB_SUBTYPE_ESS_ES1869, ess);
else
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, SB_SUBTYPE_ESS_ES1868, ess);
sb_dsp_setdma16_supported(&ess->dsp, 0);
ess_mixer_reset(ess);
/* Filters are always enabled on ES1688 and higher */
ess->mixer_ess.input_filter = 1;
ess->mixer_ess.output_filter = 1;
ess->mixer_enabled = 1;
sound_add_handler(sb_get_buffer_ess, ess);
music_add_handler(sb_get_music_buffer_ess, ess);
sound_in_add_handler(ess_put_buffer, ess);
sound_in_start_input();
sound_set_cd_audio_filter(ess_filter_cd_audio, ess);
if (device_get_config_int("control_pc_speaker"))
sound_set_pc_speaker_filter(ess_filter_pc_speaker, ess);
if (device_get_config_int("control_midi"))
sound_set_midi_filter(ess_filter_midi, ess);
if (device_get_config_int("receive_input"))
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, sb_dsp_input_remain, &ess->dsp);
ess->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
/* NOTE: The MPU is initialized disabled and with no IRQ assigned.
* It will be later initialized by the guest OS's drivers. */
mpu401_init(ess->mpu, 0, -1, M_UART, device_get_config_int("receive_input401"));
sb_dsp_set_mpu(&ess->dsp, ess->mpu);
ess->gameport = gameport_add(&gameport_pnp_device);
/* On-board chips have their IDE interface left unconnected. */
if (!(info->local & 2)) {
device_add(&ide_qua_pnp_device);
other_ide_present++;
ess->has_ide = 1;
}
const char *pnp_rom_file = NULL;
uint16_t pnp_rom_len = 512;
if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1868) {
pnp_rom_file = PNP_ROM_ESS1868;
pnp_rom_len = 324;
} else if (ess->dsp.sb_subtype == SB_SUBTYPE_ESS_ES1869) {
pnp_rom_file = PNP_ROM_ESS1869;
pnp_rom_len = 397;
}
uint8_t *pnp_rom = NULL;
if (pnp_rom_file) {
FILE *fp = rom_fopen(pnp_rom_file, "rb");
if (fp) {
if (fread(ess->pnp_rom, 1, pnp_rom_len, fp) == pnp_rom_len)
pnp_rom = ess->pnp_rom;
fclose(fp);
}
}
ess->pnp_card = isapnp_add_card(pnp_rom, sizeof(ess->pnp_rom), ess_186x_pnp_config_changed,
NULL, NULL, NULL, ess);
io_sethandler(0x0279, 0x0001, NULL, NULL, NULL, es186x_pnp_write, NULL, NULL, ess);
ess->es186x_bypass_conf = (isapnp_device_config_t *) calloc(1, sizeof(isapnp_device_config_t));
sb_dsp_setaddr(&ess->dsp, 0);
sb_dsp_setirq(&ess->dsp, 0);
sb_dsp_setdma8(&ess->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_8(&ess->dsp, ISAPNP_DMA_DISABLED);
mpu401_change_addr(ess->mpu, 0);
ess->gameport_addr = 0;
gameport_remap(ess->gameport, 0);
if (ess->has_ide)
ide_remove_handlers(3);
sound_add_handler(sb_get_buffer_ess_dac2, ess);
timer_add(&ess->ess_dac2_timer, ess_dac2_poll, ess, 0);
ess->ess_dac2_irq = 0; /* Use shared IRQ */
ess->ess_dac2_dma = ISAPNP_DMA_DISABLED;
ess->dsp.es188x_irq_mode = 1;
/* Initialize ESS filter to 8 kHz. This will be recalculated when a set frequency command is
sent. */
recalc_ess_dac2_filter(8000 * 2);
ess->mixer_ess.output_filter_dac2 = 1;
/* Init read-only control registers */
ess->es186x_ctrl_iregs[0x20] = 0x59;
ess->es186x_ctrl_iregs[0x21] = 0xA7;
ess->es186x_ctrl_iregs[0x22] = 0xCB;
ess->es186x_ctrl_iregs[0x23] = 0x10;
ess->es186x_ctrl_iregs[0x24] = 0x53;
ess->es186x_ctrl_iregs[0x25] = 0x02;
ess->es186x_ctrl_iregs[0x26] = 0x0C;
/* Calculate 6-bit attenuation values for ES1788+ master volume control */
uint8_t c;
double attenuation;
for (c = 0; c < 64; c++) {
attenuation = -47.25;
if (c & 0x01)
attenuation += 0.75;
if (c & 0x02)
attenuation += 1.5;
if (c & 0x04)
attenuation += 3.0;
if (c & 0x08)
attenuation += 6.0;
if (c & 0x10)
attenuation += 12.0;
if (c & 0x20)
attenuation += 24.0;
attenuation = pow(10, attenuation / 10);
ess_att_6bits[c] = (attenuation * 65536);
}
for (c = 0; c < 16; c++) {
attenuation = -6.0;
if (c & 0x01)
attenuation += 1.5;
if (c & 0x02)
attenuation += 3.0;
if (c & 0x04)
attenuation += 6.0;
if (c & 0x08)
attenuation += 12.0;
attenuation = pow(10, attenuation / 10);
ess_input_gain_vols_4bits[c] = (int) (attenuation);
}
return ess;
}
/*
* ESS Solo-1 DOS mode
*/
static int
solo1_legacy_dma_readb(void *priv)
{
sb_t *ess = (sb_t *) priv;
int ch = ess->dsp.sb_8_dmanum;
int ret = dma_channel_read(ch);
return ret;
}
static int
solo1_legacy_dma_readw(void *priv)
{
sb_t *ess = (sb_t *) priv;
int ch = ess->dsp.sb_16_dmanum;
int lo = dma_channel_read(ch);
int hi;
if (lo & DMA_NODATA)
return lo;
hi = dma_channel_read(ch);
if (hi & DMA_NODATA)
return hi;
return (lo & 0xff) | ((hi & 0xff) << 8);
}
static int
solo1_legacy_dma_writeb(void *priv, uint8_t val)
{
sb_t *ess = (sb_t *) priv;
int ch = ess->dsp.sb_8_dmanum;
int ret = dma_channel_write(ch, val);
return ret == DMA_NODATA;
}
static int
solo1_legacy_dma_writew(void *priv, uint16_t val)
{
sb_t *ess = (sb_t *) priv;
int ch = ess->dsp.sb_16_dmanum;
int ret;
ret = dma_channel_write(ch, val & 0xff);
if (ret == DMA_NODATA)
return 1;
ret = dma_channel_write(ch, val >> 8);
return ret == DMA_NODATA;
}
/* sb_doreset() is needed for the Solo-1 but appears to not be declared,
* so doing it here to keep it local
*/
extern void sb_doreset(sb_dsp_t *dsp);
void *
ess_solo1_legacy_init(void)
{
sb_t *ess = (sb_t *) calloc(1, sizeof(sb_t));
ess->opl_enabled = 1;
fm_driver_get_cs(FM_ESFM, &ess->opl);
sb_dsp_set_real_opl(&ess->dsp, 1);
sb_dsp_init(&ess->dsp, SBPRO_DSP_301, SB_SUBTYPE_ESS_ES1869, ess);
sb_dsp_dma_attach(&ess->dsp,
solo1_legacy_dma_readb,
solo1_legacy_dma_readw,
solo1_legacy_dma_writeb,
solo1_legacy_dma_writew,
ess);
sb_dsp_setdma16_supported(&ess->dsp, 0);
ess_solo1_mixer_reset(ess);
ess->mixer_ess.input_filter = 1;
ess->mixer_ess.output_filter = 1;
ess->mixer_enabled = 1;
sound_add_handler(sb_get_buffer_ess, ess);
music_add_handler(sb_get_music_buffer_ess, ess);
sound_set_cd_audio_filter(ess_filter_cd_audio, ess);
ess->mpu = (mpu_t *) calloc(1, sizeof(mpu_t));
mpu401_init(ess->mpu, 0, -1, M_UART, 0);
sb_dsp_set_mpu(&ess->dsp, ess->mpu);
ess->gameport = gameport_add(&gameport_pnp_device);
sb_dsp_setaddr(&ess->dsp, 0);
sb_dsp_setirq(&ess->dsp, 0);
sb_dsp_setdma8(&ess->dsp, ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_8(&ess->dsp, ISAPNP_DMA_DISABLED);
mpu401_change_addr(ess->mpu, 0);
mpu401_setirq(ess->mpu, -1);
gameport_remap(ess->gameport, 0);
return ess;
}
void
ess_solo1_legacy_reset(void *priv)
{
sb_t *ess = (sb_t *) priv;
if (ess == NULL)
return;
sb_doreset(&ess->dsp);
memset(ess->dsp.ess_regs, 0x00, sizeof(ess->dsp.ess_regs));
ess->dsp.ess_regs[0x05] = 0xf8; /* A5h reset value used by sb_doreset(). */
ess->dsp.ess_playback_mode = 0;
ess->dsp.ess_irq_generic = 0;
ess->dsp.ess_irq_dmactr = 0;
ess->dsp.ess_dma_counter = 0;
ess_solo1_mixer_reset(ess);
ess->mixer_ess.input_filter = 1;
ess->mixer_ess.output_filter = 1;
ess->mixer_enabled = 1;
}
void
ess_solo1_legacy_config(void *priv, uint16_t sb_addr, int sb_enable,
int fm_enable, int fm_legacy_alias,
uint16_t mpu_addr, int mpu_enable,
int sb_irq, int mpu_irq, int dma, uint16_t game_addr)
{
sb_t *ess = (sb_t *) priv;
uint16_t old_sb;
if (ess == NULL)
return;
old_sb = ess->dsp.sb_addr;
if (old_sb) {
io_removehandler(old_sb, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(old_sb + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(old_sb + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
io_removehandler(old_sb + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_solo1_mixer_write, NULL, NULL,
ess);
io_removehandler(old_sb + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(old_sb + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_removehandler(old_sb + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
}
if (ess->opl_pnp_addr) {
io_removehandler(ess->opl_pnp_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_removehandler(ess->opl_pnp_addr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
ess->opl_pnp_addr = 0;
}
sb_dsp_setaddr(&ess->dsp, 0);
mpu401_change_addr(ess->mpu, 0);
mpu401_setirq(ess->mpu, -1);
if (ess->gameport != NULL)
gameport_remap(ess->gameport, 0);
sb_dsp_setirq(&ess->dsp, sb_enable ? sb_irq : 0);
sb_dsp_setdma8(&ess->dsp, sb_enable ? dma : ISAPNP_DMA_DISABLED);
sb_dsp_setdma16_8(&ess->dsp, sb_enable ? dma : ISAPNP_DMA_DISABLED);
if (sb_enable) {
if (fm_enable) {
io_sethandler(sb_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(sb_addr + 8, 0x0002,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(sb_addr + 8, 0x0002,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
io_sethandler(sb_addr + 4, 0x0002,
ess_mixer_read, NULL, NULL,
ess_solo1_mixer_write, NULL, NULL,
ess);
sb_dsp_setaddr(&ess->dsp, sb_addr);
io_sethandler(sb_addr + 2, 0x0003,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(sb_addr + 6, 0x0001,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
io_sethandler(sb_addr + 0x0a, 0x0006,
ess_base_read, NULL, NULL,
ess_base_write, NULL, NULL,
ess);
}
if (fm_enable && fm_legacy_alias) {
ess->opl_pnp_addr = 0x0388;
io_sethandler(ess->opl_pnp_addr, 0x0004,
ess->opl.read, NULL, NULL,
ess->opl.write, NULL, NULL,
ess->opl.priv);
io_sethandler(ess->opl_pnp_addr, 0x0004,
ess_fm_midi_read, NULL, NULL,
ess_fm_midi_write, NULL, NULL,
ess);
}
if (mpu_enable) {
ess->midi_addr = mpu_addr;
mpu401_change_addr(ess->mpu, mpu_addr);
mpu401_setirq(ess->mpu, mpu_irq);
} else
ess->midi_addr = 0;
ess->gameport_addr = game_addr;
if (ess->gameport != NULL)
gameport_remap(ess->gameport, ess->gameport_addr);
}
void
ess_solo1_legacy_mix_esfm(void *priv, int32_t *buffer, uint16_t len)
{
sb_t *ess = (sb_t *) priv;
const int32_t *opl_buf;
if (ess == NULL || !ess->opl_enabled || buffer == NULL || !len)
return;
opl_buf = ess->opl.update(ess->opl.priv);
if (opl_buf != NULL) {
for (uint32_t c = 0; c < (uint32_t) len * 2; c++)
buffer[c] += (int32_t) ((double) opl_buf[c] * 0.7171630859375);
}
ess->opl.reset_buffer(ess->opl.priv);
}
uint8_t
ess_solo1_legacy_fm_read(void *priv, uint16_t addr)
{
sb_t *ess = (sb_t *) priv;
if (ess == NULL || !ess->opl_enabled)
return 0xff;
return ess->opl.read(addr, ess->opl.priv);
}
void
ess_solo1_legacy_fm_write(void *priv, uint16_t addr, uint8_t val)
{
sb_t *ess = (sb_t *) priv;
if (ess == NULL || !ess->opl_enabled)
return;
ess->opl.write(addr, val, ess->opl.priv);
}
void
ess_solo1_legacy_mixer_write(void *priv, uint8_t index, uint8_t val)
{
sb_t *ess = (sb_t *) priv;
if (ess == NULL)
return;
ess->mixer_ess.index = index;
ess_solo1_mixer_write(5, val, ess);
}
double
ess_solo1_legacy_audio2_gain(void *priv, int channel)
{
const sb_t *ess;
const ess_mixer_t *mixer;
double source;
double master;
ess = (const sb_t *) priv;
if (ess == NULL)
return 0.0;
mixer = &ess->mixer_ess;
source = channel ? mixer->dac2_r : mixer->dac2_l;
master = channel ? mixer->master_r : mixer->master_l;
return source * master;
}
uint8_t
ess_solo1_legacy_mpu_read(void *priv, uint16_t addr)
{
sb_t *ess = (sb_t *) priv;
if (ess == NULL || ess->mpu == NULL)
return 0xff;
return mpu401_read(addr, ess->mpu);
}
void
ess_solo1_legacy_mpu_write(void *priv, uint16_t addr, uint8_t val)
{
sb_t *ess = (sb_t *) priv;
if (ess == NULL || ess->mpu == NULL)
return;
mpu401_write(addr, val, ess->mpu);
}
void
ess_solo1_legacy_close(void *priv)
{
ess_solo1_legacy_config(priv, 0, 0, 0, 0, 0, 0, 0, 0,
ISAPNP_DMA_DISABLED, 0);
sb_close(priv);
}
void
sb_close(void *priv)
{
sb_t *sb = (sb_t *) priv;
sb_dsp_close(&sb->dsp);
free(sb);
}
static void
sb_goldfinch_close(void *priv)
{
goldfinch_t *goldfinch = (goldfinch_t *) priv;
emu8k_close(&goldfinch->emu8k);
free(goldfinch);
}
static void
sb_awe32_close(void *priv)
{
sb_t *sb = (sb_t *) priv;
emu8k_close(&sb->emu8k);
sb_close(sb);
}
void
sb_speed_changed(void *priv)
{
sb_t *sb = (sb_t *) priv;
sb_dsp_speed_changed(&sb->dsp);
}
// clang-format off
static const device_config_t sb_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x210", .value = 0x210 },
{ .description = "0x220", .value = 0x220 },
{ .description = "0x230", .value = 0x230 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x250", .value = 0x250 },
{ .description = "0x260", .value = 0x260 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 7,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 3", .value = 3 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SB_DSP_105,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "1.03", .value = SB_DSP_103 },
{ .description = "1.05", .value = SB_DSP_105 },
{ .description = "2.00", .value = SB_DSP_200 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t thunderboard_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x210", .value = 0x210 },
{ .description = "0x220", .value = 0x220 },
{ .description = "0x230", .value = 0x230 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x250", .value = 0x250 },
{ .description = "0x260", .value = 0x260 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 7,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 3", .value = 3 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb15_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x210", .value = 0x210 },
{ .description = "0x220", .value = 0x220 },
{ .description = "0x230", .value = 0x230 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x250", .value = 0x250 },
{ .description = "0x260", .value = 0x260 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 7,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 3", .value = 3 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "cms",
.description = "Enable CMS",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SB_DSP_200,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "1.05", .value = SB_DSP_105 },
{ .description = "2.00", .value = SB_DSP_200 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb2_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x240", .value = 0x240 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "mixaddr",
.description = "Mixer",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0 },
{ .description = "0x250", .value = 0x250 },
{ .description = "0x260", .value = 0x260 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 3", .value = 3 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "cms",
.description = "Enable CMS",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SB_DSP_201,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "2.01", .value = SB_DSP_201 },
{ .description = "2.02", .value = SB_DSP_202 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_mcv_config[] = {
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 7,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 3", .value = 3 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_pro_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x240", .value = 0x240 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 7,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "IRQ 10", .value = 10 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 0", .value = 0 },
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SBPRO_DSP_300,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "3.00", .value = SBPRO_DSP_300 },
{ .description = "3.01", .value = SBPRO_DSP_301 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_pro_v2_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x240", .value = 0x240 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 7,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "IRQ 10", .value = 10 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 0", .value = 0 },
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SBPRO_DSP_302,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "3.01", .value = SBPRO_DSP_301 },
{ .description = "3.02", .value = SBPRO_DSP_302 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_pro_mcv_config[] = {
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_16_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x260", .value = 0x260 },
{ .description = "0x280", .value = 0x280 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "base401",
.description = "MPU-401 Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x330,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0 },
{ .description = "0x300", .value = 0x300 },
{ .description = "0x330", .value = 0x330 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "IRQ 10", .value = 10 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "Low DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 0", .value = 0 },
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma16",
.description = "High DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 5", .value = 5 },
{ .description = "DMA 6", .value = 6 },
{ .description = "DMA 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SB16_DSP_405,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "4.04", .value = SB16_DSP_404 },
{ .description = "4.05", .value = SB16_DSP_405 },
{ .description = "4.11", .value = SB16_DSP_411 },
{ .description = "4.12", .value = SBAWE32_DSP_412 },
{ .description = "4.13", .value = SBAWE32_DSP_413 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_vibra16_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x260", .value = 0x260 },
{ .description = "0x280", .value = 0x280 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "base401",
.description = "MPU-401 Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x330,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0 },
{ .description = "0x300", .value = 0x300 },
{ .description = "0x330", .value = 0x330 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "IRQ 10", .value = 10 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "Low DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 0", .value = 0 },
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma16",
.description = "High DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 5", .value = 5 },
{ .description = "DMA 6", .value = 6 },
{ .description = "DMA 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_16_pnp_config[] = {
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SB16_DSP_405,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "4.04", .value = SB16_DSP_404 },
{ .description = "4.05", .value = SB16_DSP_405 },
{ .description = "4.11", .value = SB16_DSP_411 },
{ .description = "4.12", .value = SBAWE32_DSP_412 },
{ .description = "4.13", .value = SBAWE32_DSP_413 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_vibra16_pnp_config[] = {
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_goldfinch_config[] = {
{
.name = "onboard_ram",
.description = "Memory size",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "None", .value = 0 },
{ .description = "512 KB", .value = 512 },
{ .description = "1 MB", .value = 1024 },
{ .description = "2 MB", .value = 2048 },
{ .description = "4 MB", .value = 4096 },
{ .description = "8 MB", .value = 8192 },
{ .description = "16 MB", .value = 16384 },
{ .description = "28 MB", .value = 28672 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_32_pnp_config[] = {
{
.name = "onboard_ram",
.description = "Memory size",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "None", .value = 0 },
{ .description = "512 KB", .value = 512 },
{ .description = "2 MB", .value = 2048 },
{ .description = "8 MB", .value = 8192 },
{ .description = "28 MB", .value = 28672 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_awe32_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x260", .value = 0x260 },
{ .description = "0x280", .value = 0x280 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "emu_base",
.description = "EMU8000 Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x620,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x620", .value = 0x620 },
{ .description = "0x640", .value = 0x640 },
{ .description = "0x660", .value = 0x660 },
{ .description = "0x680", .value = 0x680 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "base401",
.description = "MPU-401 Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x330,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0 },
{ .description = "0x300", .value = 0x300 },
{ .description = "0x330", .value = 0x330 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "IRQ 10", .value = 10 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "Low DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 0", .value = 0 },
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma16",
.description = "High DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 5", .value = 5 },
{ .description = "DMA 6", .value = 6 },
{ .description = "DMA 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "onboard_ram",
.description = "Memory size",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 512,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "None", .value = 0 },
{ .description = "512 KB", .value = 512 },
{ .description = "2 MB", .value = 2048 },
{ .description = "8 MB", .value = 8192 },
{ .description = "28 MB", .value = 28672 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "opl",
.description = "Enable OPL",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = SBAWE32_DSP_412,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "4.12", .value = SBAWE32_DSP_412 },
{ .description = "4.13", .value = SBAWE32_DSP_413 },
{ .description = "" }
},
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_awe32_pnp_config[] = {
{
.name = "onboard_ram",
.description = "Memory size",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 512,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "None", .value = 0 },
{ .description = "512 KB", .value = 512 },
{ .description = "2 MB", .value = 2048 },
{ .description = "8 MB", .value = 8192 },
{ .description = "28 MB", .value = 28672 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_awe64_value_config[] = {
{
.name = "onboard_ram",
.description = "Memory size",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 512,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "512 KB", .value = 512 },
{ .description = "1 MB", .value = 1024 },
{ .description = "2 MB", .value = 2048 },
{ .description = "4 MB", .value = 4096 },
{ .description = "8 MB", .value = 8192 },
{ .description = "12 MB", .value = 12288 },
{ .description = "16 MB", .value = 16384 },
{ .description = "20 MB", .value = 20480 },
{ .description = "24 MB", .value = 24576 },
{ .description = "28 MB", .value = 28672 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_awe64_config[] = {
{
.name = "onboard_ram",
.description = "Memory size",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1024,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "1 MB", .value = 1024 },
{ .description = "2 MB", .value = 2048 },
{ .description = "4 MB", .value = 4096 },
{ .description = "8 MB", .value = 8192 },
{ .description = "12 MB", .value = 12288 },
{ .description = "16 MB", .value = 16384 },
{ .description = "20 MB", .value = 20480 },
{ .description = "24 MB", .value = 24576 },
{ .description = "28 MB", .value = 28672 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t sb_awe64_gold_config[] = {
{
.name = "onboard_ram",
.description = "Memory size",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 4096,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "4 MB", .value = 4096 },
{ .description = "8 MB", .value = 8192 },
{ .description = "12 MB", .value = 12288 },
{ .description = "16 MB", .value = 16384 },
{ .description = "20 MB", .value = 20480 },
{ .description = "24 MB", .value = 24576 },
{ .description = "28 MB", .value = 28672 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t ess_488_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x230", .value = 0x230 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x250", .value = 0x250 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 3", .value = 3 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t ess_688_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x230", .value = 0x230 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x250", .value = 0x250 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "IRQ 10", .value = 10 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 0", .value = 0 },
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "ide_ctrl",
.description = "IDE Controller",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x0000,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0x0000 },
{ .description = "0x170, IRQ 15", .value = 0xf170 },
{ .description = "0x1E8, IRQ 11", .value = 0xb1e8 },
{ .description = "0x168, IRQ 9", .value = 0x9168 },
{ .description = "0x168, IRQ 10", .value = 0xa168 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "3.01", .value = 0 },
{ .description = "2.01", .value = 1 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t ess_1688_config[] = {
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x220,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "0x220", .value = 0x220 },
{ .description = "0x230", .value = 0x230 },
{ .description = "0x240", .value = 0x240 },
{ .description = "0x250", .value = 0x250 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 5,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "IRQ 2", .value = 2 },
{ .description = "IRQ 5", .value = 5 },
{ .description = "IRQ 7", .value = 7 },
{ .description = "IRQ 10", .value = 10 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "DMA 0", .value = 0 },
{ .description = "DMA 1", .value = 1 },
{ .description = "DMA 3", .value = 3 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "gameport",
.description = "Enable Game port",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "ide_ctrl",
.description = "IDE Controller",
.type = CONFIG_HEX16,
.default_string = NULL,
.default_int = 0x0000,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0x0000 },
{ .description = "0x170, IRQ 15", .value = 0xf170 },
{ .description = "0x1E8, IRQ 11", .value = 0xb1e8 },
{ .description = "0x168, IRQ 9", .value = 0x9168 },
{ .description = "0x168, IRQ 10", .value = 0xa168 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "dspver",
.description = "DSP Version",
.type = CONFIG_SELECTION,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = {
{ .description = "3.01", .value = 0 },
{ .description = "2.01", .value = 1 },
{ .description = "" }
},
.bios = { { 0 } }
},
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t ess_688_pnp_config[] = {
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t ess_688_pnp_es0968_config[] = {
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
static const device_config_t ess_1688_pnp_config[] = {
{
.name = "control_pc_speaker",
.description = "Control PC speaker",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "control_midi",
.description = "Control MIDI volume",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input",
.description = "Receive MIDI input",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 1,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{
.name = "receive_input401",
.description = "Receive MIDI input (MPU-401)",
.type = CONFIG_BINARY,
.default_string = NULL,
.default_int = 0,
.file_filter = NULL,
.spinner = { 0 },
.selection = { { 0 } },
.bios = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
};
// clang-format on
const device_t thunderboard_device = {
.name = "Media Vision Thunder Board",
.internal_name = "thunderboard",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = THUNDERBOARD,
.init = thunderboard_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = thunderboard_config
};
const device_t sb_1_device = {
.name = "Sound Blaster v1.0",
.internal_name = "sb",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = SB_1,
.init = sb_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_config
};
const device_t sb_15_device = {
.name = "Sound Blaster v1.5",
.internal_name = "sb1.5",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = SB_15,
.init = sb_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb15_config
};
const device_t sb_mcv_device = {
.name = "Sound Blaster MCV",
.internal_name = "sbmcv",
.flags = DEVICE_MCA | DEVICE_AUDIO_IN,
.local = 0,
.init = sb_mcv_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_mcv_config
};
const device_t sb_2_device = {
.name = "Sound Blaster v2.0",
.internal_name = "sb2.0",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = SB_2,
.init = sb_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb2_config
};
const device_t sb_pro_v1_device = {
.name = "Sound Blaster Pro v1",
.internal_name = "sbprov1",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = 0,
.init = sb_pro_v1_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_pro_config
};
const device_t sb_pro_v2_device = {
.name = "Sound Blaster Pro v2",
.internal_name = "sbprov2",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = 0,
.init = sb_pro_v2_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_pro_v2_config
};
const device_t sb_pro_mcv_device = {
.name = "Sound Blaster Pro MCV",
.internal_name = "sbpromcv",
.flags = DEVICE_MCA | DEVICE_AUDIO_IN,
.local = 0,
.init = sb_pro_mcv_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_pro_mcv_config
};
const device_t sb_pro_compat_device = {
.name = "Sound Blaster Pro (Compatibility)",
.internal_name = "sbpro_compat",
.flags = DEVICE_ISA16,
.local = 0,
.init = sb_pro_compat_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = NULL
};
const device_t sb_16_device = {
.name = "Sound Blaster 16",
.internal_name = "sb16",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = FM_YMF262,
.init = sb_16_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_16_config
};
const device_t sb_vibra16c_onboard_device = {
.name = "Sound Blaster ViBRA 16C (On-Board)",
.internal_name = "sb_vibra16c_onboard",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_VIBRA16C,
.init = sb_vibra16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_vibra16c_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_pnp_config
};
const device_t sb_vibra16c_device = {
.name = "Sound Blaster ViBRA 16C",
.internal_name = "sb_vibra16c",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_VIBRA16C,
.init = sb_vibra16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_vibra16c_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_pnp_config
};
const device_t sb_vibra16cl_onboard_device = {
.name = "Sound Blaster ViBRA 16CL (On-Board)",
.internal_name = "sb_vibra16cl_onboard",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_VIBRA16CL,
.init = sb_vibra16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_vibra16cl_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_pnp_config
};
const device_t sb_vibra16cl_device = {
.name = "Sound Blaster ViBRA 16CL",
.internal_name = "sb_vibra16cl",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_VIBRA16CL,
.init = sb_vibra16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_vibra16cl_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_pnp_config
};
const device_t sb_vibra16s_onboard_device = {
.name = "Sound Blaster ViBRA 16S (On-Board)",
.internal_name = "sb_vibra16s_onboard",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = FM_YMF289B,
.init = sb_16_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_16_config
};
const device_t sb_vibra16s_device = {
.name = "Sound Blaster ViBRA 16S",
.internal_name = "sb_vibra16s",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = FM_YMF289B,
.init = sb_16_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_config
};
const device_t sb_vibra16xv_onboard_device = {
.name = "Sound Blaster ViBRA 16XV (On-Board)",
.internal_name = "sb_vibra16xv_onboard",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_VIBRA16XV,
.init = sb_vibra16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_vibra16xv_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_pnp_config
};
const device_t sb_vibra16xv_device = {
.name = "Sound Blaster ViBRA 16XV",
.internal_name = "sb_vibra16xv",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_VIBRA16XV,
.init = sb_vibra16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_vibra16xv_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_pnp_config
};
const device_t sb_16_reply_mca_device = {
.name = "Sound Blaster 16 Reply MCA",
.internal_name = "sb16_reply_mca",
.flags = DEVICE_MCA | DEVICE_AUDIO_IN,
.local = 0,
.init = sb_16_reply_mca_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_vibra16_pnp_config
};
const device_t sb_16_pnp_device = {
.name = "Sound Blaster 16 PnP",
.internal_name = "sb16_pnp",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_16_PNP_NOIDE,
.init = sb_16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_16_pnp_noide_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_16_pnp_config
};
const device_t sb_16_pnp_ide_device = {
.name = "Sound Blaster 16 PnP (IDE)",
.internal_name = "sb16_pnp_ide",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_16_PNP_IDE,
.init = sb_16_pnp_init,
.close = sb_close,
.reset = NULL,
.available = sb_16_pnp_ide_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_16_pnp_config,
.short_name = "SB16",
.ide_boards = ide_boards_quaternary
};
const device_t sb_16_compat_device = {
.name = "Sound Blaster 16 (Compatibility)",
.internal_name = "sb16_compat",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 1,
.init = sb_16_compat_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = NULL
};
const device_t sb_16_compat_nompu_device = {
.name = "Sound Blaster 16 (Compatibility - MPU-401 Off)",
.internal_name = "sb16_compat",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 0,
.init = sb_16_compat_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = NULL
};
const device_t sb_goldfinch_device = {
.name = "Creative EMU8000 PnP (Goldfinch)",
.internal_name = "sb_goldfinch",
.flags = DEVICE_ISA16,
.local = 0,
.init = sb_goldfinch_init,
.close = sb_goldfinch_close,
.reset = NULL,
.available = sb_goldfinch_available,
.speed_changed = NULL,
.force_redraw = NULL,
.config = sb_goldfinch_config
};
const device_t sb_32_pnp_device = {
.name = "Sound Blaster 32 PnP",
.internal_name = "sb32_pnp",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_32_PNP,
.init = sb_awe32_pnp_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_32_pnp_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_32_pnp_config,
.short_name = "SB32",
.ide_boards = ide_boards_quaternary
};
const device_t sb_awe32_device = {
.name = "Sound Blaster AWE32",
.internal_name = "sbawe32",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 0,
.init = sb_awe32_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_awe32_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_awe32_config
};
const device_t sb_awe32_pnp_device = {
.name = "Sound Blaster AWE32 PnP",
.internal_name = "sbawe32_pnp",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_AWE32_PNP,
.init = sb_awe32_pnp_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_awe32_pnp_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_awe32_pnp_config,
.short_name = "AWE32",
.ide_boards = ide_boards_quaternary
};
const device_t sb_awe32_ide_pnp_device = {
.name = "Sound Blaster AWE32 IDE PnP",
.internal_name = "sbawe32_ide_pnp",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_AWE32_IDE_PNP,
.init = sb_awe32_pnp_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_awe32_ide_pnp_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.alias = "Sound Blaster AWE32 IDE PnP Internet Enhanced",
.config = sb_awe32_pnp_config,
.short_name = "AWE32",
.ide_boards = ide_boards_quaternary
};
const device_t sb_awe64_value_device = {
.name = "Sound Blaster AWE64 Value",
.internal_name = "sbawe64_value",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_AWE64_VALUE,
.init = sb_awe32_pnp_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_awe64_value_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_awe64_value_config
};
const device_t sb_awe64_device = {
.name = "Sound Blaster AWE64",
.internal_name = "sbawe64",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_AWE64_NOIDE,
.init = sb_awe32_pnp_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_awe64_noide_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_awe64_config
};
const device_t sb_awe64_ide_device = {
.name = "Sound Blaster AWE64 (IDE)",
.internal_name = "sbawe64_ide",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_AWE64_IDE,
.init = sb_awe32_pnp_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_awe64_ide_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_awe64_config,
.short_name = "AWE64",
.ide_boards = ide_boards_quaternary
};
const device_t sb_awe64_gold_device = {
.name = "Sound Blaster AWE64 Gold",
.internal_name = "sbawe64_gold",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = SB_AWE64_GOLD,
.init = sb_awe32_pnp_init,
.close = sb_awe32_close,
.reset = NULL,
.available = sb_awe64_gold_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = sb_awe64_gold_config
};
const device_t ess_488_device = {
.name = "ESS AudioDrive ES488",
.internal_name = "ess_es488",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = 0,
.init = ess_x488_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_488_config
};
const device_t ess_1488_device = {
.name = "ESS AudioDrive ES1488",
.internal_name = "ess_es1488",
.flags = DEVICE_ISA | DEVICE_AUDIO_IN,
.local = 1,
.init = ess_x488_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_488_config
};
const device_t ess_688_device = {
.name = "ESS AudioDrive ES688",
.internal_name = "ess_es688",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 0,
.init = ess_x688_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_688_config,
.short_name = "ESS ES688",
.ide_boards = ess_x688_ide_boards
};
const device_t ess_ess0100_pnp_device = {
.name = "ESS AudioDrive ES688 (ESS0100) PnP",
.internal_name = "ess_ess0100_pnp",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 0,
.init = ess_x688_pnp_init,
.close = sb_close,
.reset = NULL,
.available = ess_688_pnp_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_688_pnp_config,
.short_name = "ESS ES688",
.ide_boards = ide_boards_quaternary
};
const device_t ess_1688_device = {
.name = "ESS AudioDrive ES1688",
.internal_name = "ess_es1688",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 1,
.init = ess_x688_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_config,
.short_name = "ESS ES1688",
.ide_boards = ess_x688_ide_boards
};
const device_t ess_1688_compaq_device = {
.name = "ESS AudioDrive ES1688 (Compaq)",
.internal_name = "ess_es1688_compaq",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 0,
.init = ess_1x88_onboard_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};
const device_t ess_ess0102_pnp_device = {
.name = "ESS AudioDrive ES1688 (ESS0102) PnP",
.internal_name = "ess_ess0102_pnp",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 1,
.init = ess_x688_pnp_init,
.close = sb_close,
.reset = NULL,
.available = ess_1688_pnp_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config,
.short_name = "ESS ES1688",
.ide_boards = ide_boards_quaternary
};
const device_t ess_ess0968_pnp_688_device = {
.name = "ESS AudioDrive ES688 (ESS0968) PnP",
.internal_name = "ess_ess0968_pnp_es688",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 2,
.init = ess_x688_pnp_init,
.close = sb_close,
.reset = NULL,
.available = ess_1688_968_pnp_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_688_pnp_es0968_config,
.short_name = "ESS ES688",
.ide_boards = ide_boards_quaternary
};
const device_t ess_ess0968_pnp_device = {
.name = "ESS AudioDrive ES1688 (ESS0968) PnP",
.internal_name = "ess_ess0968_pnp",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 3,
.init = ess_x688_pnp_init,
.close = sb_close,
.reset = NULL,
.available = ess_1688_968_pnp_available,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config,
.short_name = "ESS ES1688",
.ide_boards = ide_boards_quaternary
};
const device_t ess_soundpiper_16_mca_device = {
.name = "SoundPiper 16 (ESS AudioDrive ES688) MCA",
.internal_name = "soundpiper_16_mca",
.flags = DEVICE_MCA | DEVICE_AUDIO_IN,
.local = 0,
.init = ess_x688_mca_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_688_pnp_config
};
const device_t ess_soundpiper_32_mca_device = {
.name = "SoundPiper 32 (ESS AudioDrive ES1688) MCA",
.internal_name = "soundpiper_32_mca",
.flags = DEVICE_MCA | DEVICE_AUDIO_IN,
.local = 1,
.init = ess_x688_mca_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};
const device_t ess_chipchat_16_mca_device = {
.name = "ChipChat 16 (ESS AudioDrive ES1688) MCA",
.internal_name = "chipchat_16_mca",
.flags = DEVICE_MCA | DEVICE_AUDIO_IN,
.local = 2,
.init = ess_x688_mca_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};
const device_t ess_1788_device = {
.name = "ESS AudioDrive ES1788/ES1698", /* ES1698 is a rebadged ES1788 */
.internal_name = "ess_es1788",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 1,
.init = ess_1x88_onboard_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};
const device_t ess_1888_device = {
.name = "ESS AudioDrive ES1888",
.internal_name = "ess_es1888",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 2,
.init = ess_1x88_onboard_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};
const device_t ess_1888_compaq_device = {
.name = "ESS AudioDrive ES1888 (Compaq)",
.internal_name = "ess_es1888_compaq",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 0x12,
.init = ess_1x88_onboard_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};
const device_t ess_1887_device = {
.name = "ESS AudioDrive ES1887",
.internal_name = "ess_es1887",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 3,
.init = ess_1x88_onboard_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};
const device_t ess_1868_device = {
.name = "ESS AudioDrive ES1868",
.internal_name = "ess_es1868",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 0,
.init = ess_186x_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config,
.short_name = "ESS ES1868",
.ide_boards = ide_boards_quaternary
};
const device_t ess_1869_device = {
.name = "ESS AudioDrive ES1869",
.internal_name = "ess_es1869",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 1,
.init = ess_186x_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config,
.short_name = "ESS ES1869",
.ide_boards = ide_boards_quaternary
};
const device_t ess_1869_onboard_device = {
.name = "ESS AudioDrive ES1869 (On-Board)",
.internal_name = "ess_es1869_onboard",
.flags = DEVICE_ISA16 | DEVICE_AUDIO_IN,
.local = 1 | 2,
.init = ess_186x_init,
.close = sb_close,
.reset = NULL,
.available = NULL,
.speed_changed = sb_speed_changed,
.force_redraw = NULL,
.config = ess_1688_pnp_config
};