Merge pull request #5099 from jriwanek-forks/es1370
More fixes to parens and normalization of es1370, and cleaning in snd_sb.c too
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Ensoniq AudioPCI family emulation.
|
||||
* Ensoniq AudioPCI family emulation.
|
||||
*
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* RichardG, <richardg867@gmail.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Jasmine Iwanek, <jriwanek@gmail.com>
|
||||
* Cacodemon345
|
||||
* Authors: Sarah Walker, <https://pcem-emulator.co.uk/>
|
||||
* RichardG, <richardg867@gmail.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Jasmine Iwanek, <jriwanek@gmail.com>
|
||||
* Cacodemon345
|
||||
*
|
||||
* Copyright 2008-2021 Sarah Walker.
|
||||
* Copyright 2021-2024 RichardG.
|
||||
* Copyright 2021 Miran Grca.
|
||||
* Copyright 2024-2025 Jasmine Iwanek.
|
||||
* Copyright 2024-2025 Cacodemon345.
|
||||
* Copyright 2008-2021 Sarah Walker.
|
||||
* Copyright 2021-2024 RichardG.
|
||||
* Copyright 2021 Miran Grca.
|
||||
* Copyright 2024-2025 Jasmine Iwanek.
|
||||
* Copyright 2024-2025 Cacodemon345.
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
@@ -145,10 +145,10 @@ typedef struct es137x_t {
|
||||
uint32_t calc_sample_rate;
|
||||
uint32_t calc_sample_rate_synth;
|
||||
|
||||
double interp_factor;
|
||||
double interp_factor;
|
||||
uint32_t interp_step;
|
||||
|
||||
double interp_factor_synth;
|
||||
double interp_factor_synth;
|
||||
uint32_t interp_step_synth;
|
||||
|
||||
uint32_t step_pcm;
|
||||
@@ -156,18 +156,20 @@ typedef struct es137x_t {
|
||||
} es137x_t;
|
||||
|
||||
static const double akm4531_att_2dbstep_5bits[] = {
|
||||
// clang-format off
|
||||
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
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static double akm4531_gain_2dbstep_5bits[0x20];
|
||||
|
||||
#define AUDIOPCI_ES1370 0x50001271
|
||||
#define AUDIOPCI_ES1371 0x13710200
|
||||
#define AUDIOPCI_ES1373 0x13710400
|
||||
#define AUDIOPCI_CT5880 0x58800400
|
||||
#define AUDIOPCI_ES1370 0x50000000
|
||||
#define AUDIOPCI_ES1371 0x13710200
|
||||
#define AUDIOPCI_ES1373 0x13710400
|
||||
#define AUDIOPCI_CT5880 0x58800400
|
||||
|
||||
#define LEGACY_SB_ADDR (1 << 29)
|
||||
#define LEGACY_SSCAPE_ADDR_SHIFT 27
|
||||
@@ -365,7 +367,7 @@ es137x_reset_fifo(es137x_t *dev)
|
||||
static void
|
||||
akm4531_reset(es137x_t *dev)
|
||||
{
|
||||
akm4531_t* codec = &dev->akm_codec;
|
||||
akm4531_t *codec = &dev->akm_codec;
|
||||
|
||||
memset(codec->registers, 0, sizeof(codec->registers));
|
||||
|
||||
@@ -382,8 +384,10 @@ akm4531_reset(es137x_t *dev)
|
||||
codec->registers[0x16] = 0x3;
|
||||
}
|
||||
|
||||
static double lerp(double v0, double v1, double t) {
|
||||
return (1. - t) * v0 + t * v1;
|
||||
static double
|
||||
lerp(double v0, double v1, double t)
|
||||
{
|
||||
return (1. - t) * v0 + t * v1;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -394,34 +398,34 @@ es1370_calc_sample_rate(es137x_t *dev)
|
||||
|
||||
dev->calc_sample_rate = 1411200 / (((dev->int_ctrl >> 16) & 0x1fff) + 2);
|
||||
|
||||
//pclog("ES1370 calc sample rate %u\n", dev->calc_sample_rate);
|
||||
// pclog("ES1370 calc sample rate %u\n", dev->calc_sample_rate);
|
||||
|
||||
dev->interp_factor = 1.0;
|
||||
dev->interp_step = 1;
|
||||
dev->interp_step = 1;
|
||||
|
||||
if (dev->calc_sample_rate >= 44100 || dev->calc_sample_rate < 11025) {
|
||||
dev->interp_factor = 1.0;
|
||||
dev->interp_step = 1;
|
||||
dev->interp_factor = 1.0;
|
||||
dev->interp_step = 1;
|
||||
dev->calc_sample_rate = 44100;
|
||||
}
|
||||
if (dev->calc_sample_rate == 22050) {
|
||||
dev->interp_factor = 0.5;
|
||||
dev->interp_step = 2;
|
||||
dev->interp_step = 2;
|
||||
}
|
||||
if (dev->calc_sample_rate == 11025) {
|
||||
dev->interp_factor = 0.25;
|
||||
dev->interp_step = 4;
|
||||
dev->interp_step = 4;
|
||||
}
|
||||
if ((((dev->int_ctrl >> 16) & 0x1fff) + 2) == 256) {
|
||||
/* 5512.5 Hz */
|
||||
dev->interp_factor = 0.125;
|
||||
dev->interp_step = 8;
|
||||
dev->interp_factor = 0.125;
|
||||
dev->interp_step = 8;
|
||||
dev->calc_sample_rate = 5512;
|
||||
}
|
||||
|
||||
dev->calc_sample_rate_synth = 44100 / (1 << ((dev->int_ctrl >> 12) & 3));
|
||||
dev->interp_factor_synth = 1. / (double)(1 << ((dev->int_ctrl >> 12) & 3));
|
||||
dev->interp_step_synth = (1 << ((dev->int_ctrl >> 12) & 3));
|
||||
dev->interp_factor_synth = 1. / (double) (1 << ((dev->int_ctrl >> 12) & 3));
|
||||
dev->interp_step_synth = (1 << ((dev->int_ctrl >> 12) & 3));
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -432,7 +436,7 @@ es137x_reset(void *priv)
|
||||
nmi = 0;
|
||||
|
||||
/* Default subsystem ID. */
|
||||
dev->subsys_lock = 0x00;
|
||||
dev->subsys_lock = 0x00;
|
||||
*((uint16_t *) &dev->subsys_id[0]) = (dev->type == AUDIOPCI_ES1370) ? 0x4942 : 0x1274;
|
||||
*((uint16_t *) &dev->subsys_id[2]) = (dev->type == AUDIOPCI_ES1370) ? 0x4c4c : 0x1371;
|
||||
|
||||
@@ -444,7 +448,7 @@ es137x_reset(void *priv)
|
||||
Addressable as longword only */
|
||||
if (dev->type >= AUDIOPCI_CT5880)
|
||||
dev->int_status = 0x52080ec0;
|
||||
else if (dev->type >= AUDIOPCI_ES1373 && dev->type != AUDIOPCI_ES1370)
|
||||
else if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
dev->int_status = 0x7f080ec0;
|
||||
else
|
||||
dev->int_status = 0x7ffffec0;
|
||||
@@ -780,7 +784,7 @@ es137x_inb(uint16_t port, void *priv)
|
||||
break;
|
||||
case 0x03:
|
||||
ret = dev->int_ctrl >> 24;
|
||||
if (dev->type < AUDIOPCI_ES1373 && dev->type != AUDIOPCI_ES1370)
|
||||
if ((dev->type < AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret |= 0xfc;
|
||||
break;
|
||||
|
||||
@@ -853,19 +857,19 @@ es137x_inb(uint16_t port, void *priv)
|
||||
/* S/PDIF Channel Status Control Register, Address 1CH
|
||||
Addressable as byte, word, longword */
|
||||
case 0x1c:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret = dev->spdif_chstatus & 0xff;
|
||||
break;
|
||||
case 0x1d:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret = dev->spdif_chstatus >> 8;
|
||||
break;
|
||||
case 0x1e:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret = dev->spdif_chstatus >> 16;
|
||||
break;
|
||||
case 0x1f:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret = dev->spdif_chstatus >> 24;
|
||||
break;
|
||||
|
||||
@@ -906,7 +910,7 @@ es137x_inw(uint16_t port, void *priv)
|
||||
break;
|
||||
case 0x02:
|
||||
ret = (dev->int_ctrl >> 16) & 0xff0f;
|
||||
if (dev->type < AUDIOPCI_ES1373 && dev->type != AUDIOPCI_ES1370)
|
||||
if ((dev->type < AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret |= 0xfc00;
|
||||
break;
|
||||
|
||||
@@ -931,11 +935,11 @@ es137x_inw(uint16_t port, void *priv)
|
||||
/* S/PDIF Channel Status Control Register, Address 1CH
|
||||
Addressable as byte, word, longword */
|
||||
case 0x1c:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret = dev->spdif_chstatus & 0xffff;
|
||||
break;
|
||||
case 0x1e:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
ret = dev->spdif_chstatus >> 16;
|
||||
break;
|
||||
|
||||
@@ -1003,7 +1007,7 @@ es137x_inl(uint16_t port, void *priv)
|
||||
es137x_t *dev = (es137x_t *) priv;
|
||||
uint32_t ret = 0xffffffff;
|
||||
|
||||
if (dev->type == AUDIOPCI_ES1370 && (port & 0x3c) == 0x14)
|
||||
if ((dev->type == AUDIOPCI_ES1370) && (port & 0x3c) == 0x14)
|
||||
port = 0x10;
|
||||
|
||||
switch (port & 0x3c) {
|
||||
@@ -1011,7 +1015,7 @@ es137x_inl(uint16_t port, void *priv)
|
||||
Addressable as byte, word, longword */
|
||||
case 0x00:
|
||||
ret = dev->int_ctrl & 0xff0fffff;
|
||||
if (ret < AUDIOPCI_ES1373 && ret != AUDIOPCI_ES1370)
|
||||
if ((ret < AUDIOPCI_ES1373) && (ret != AUDIOPCI_ES1370))
|
||||
ret |= 0xfc000000;
|
||||
break;
|
||||
|
||||
@@ -1052,7 +1056,7 @@ es137x_inl(uint16_t port, void *priv)
|
||||
/* S/PDIF Channel Status Control Register, Address 1CH
|
||||
Addressable as byte, word, longword */
|
||||
case 0x1c:
|
||||
if (dev->type >= AUDIOPCI_ES1373 || dev->type == AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) || (dev->type != AUDIOPCI_ES1370))
|
||||
ret = dev->spdif_chstatus;
|
||||
break;
|
||||
|
||||
@@ -1123,7 +1127,7 @@ es137x_outb(uint16_t port, uint8_t val, void *priv)
|
||||
dev->dac[1].prev_out_r = 0;
|
||||
es137x_fetch(dev, 1);
|
||||
}
|
||||
//pclog("INTCTRL 0x%02X\n", val & 0xff);
|
||||
// audiopci_log("INTCTRL 0x%02X\n", val & 0xff);
|
||||
dev->int_ctrl = (dev->int_ctrl & 0xffffff00) | val;
|
||||
break;
|
||||
case 0x01:
|
||||
@@ -1144,11 +1148,11 @@ es137x_outb(uint16_t port, uint8_t val, void *priv)
|
||||
Addressable as longword only, but PCem implements byte access, which
|
||||
must be for a reason */
|
||||
case 0x06:
|
||||
if (dev->type >= AUDIOPCI_ES1373 || dev->type == AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) || (dev->type != AUDIOPCI_ES1370))
|
||||
dev->int_status = (dev->int_status & 0xff08ffff) | (val << 16);
|
||||
break;
|
||||
case 0x07:
|
||||
if (dev->type >= AUDIOPCI_CT5880 || dev->type == AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_CT5880) || (dev->type != AUDIOPCI_ES1370))
|
||||
dev->int_status = (dev->int_status & 0xd2ffffff) | (val << 24);
|
||||
break;
|
||||
|
||||
@@ -1278,7 +1282,7 @@ es137x_outw(uint16_t port, uint16_t val, void *priv)
|
||||
dev->step_pcm = dev->interp_step;
|
||||
es137x_fetch(dev, 1);
|
||||
}
|
||||
//pclog("INTCTRL 0x%02X\n", val & 0xff);
|
||||
// audiopci_log("INTCTRL 0x%02X\n", val & 0xff);
|
||||
dev->int_ctrl = (dev->int_ctrl & 0xffff0000) | val;
|
||||
break;
|
||||
case 0x02:
|
||||
@@ -1300,7 +1304,7 @@ es137x_outw(uint16_t port, uint16_t val, void *priv)
|
||||
case 0x10:
|
||||
if (dev->type != AUDIOPCI_ES1370)
|
||||
break;
|
||||
|
||||
|
||||
dev->akm_codec.registers[(val >> 8) & 0xFF] = val & 0xFF;
|
||||
if ((val >> 8) == 0x16 && !(val & 1))
|
||||
akm4531_reset(dev);
|
||||
@@ -1376,36 +1380,38 @@ es137x_outl(uint16_t port, uint32_t val, void *priv)
|
||||
/* Interrupt/Chip Select Control Register, Address 00H
|
||||
Addressable as byte, word, longword */
|
||||
case 0x00:
|
||||
{
|
||||
uint8_t dac1start = 0, dac2start = 0;
|
||||
if (!(dev->int_ctrl & INT_DAC1_EN) && (val & INT_DAC1_EN)) {
|
||||
dev->dac[0].addr = dev->dac[0].addr_latch;
|
||||
dev->dac[0].buffer_pos = 0;
|
||||
dev->dac[0].buffer_pos_end = 0;
|
||||
dev->dac[0].prev_out_l = 0;
|
||||
dev->dac[0].prev_out_r = 0;
|
||||
dac1start = 1;
|
||||
es137x_fetch(dev, 0);
|
||||
{
|
||||
uint8_t dac1start = 0;
|
||||
uint8_t dac2start = 0;
|
||||
|
||||
if (!(dev->int_ctrl & INT_DAC1_EN) && (val & INT_DAC1_EN)) {
|
||||
dev->dac[0].addr = dev->dac[0].addr_latch;
|
||||
dev->dac[0].buffer_pos = 0;
|
||||
dev->dac[0].buffer_pos_end = 0;
|
||||
dev->dac[0].prev_out_l = 0;
|
||||
dev->dac[0].prev_out_r = 0;
|
||||
dac1start = 1;
|
||||
es137x_fetch(dev, 0);
|
||||
}
|
||||
if (!(dev->int_ctrl & INT_DAC2_EN) && (val & INT_DAC2_EN)) {
|
||||
dev->dac[1].addr = dev->dac[1].addr_latch;
|
||||
dev->dac[1].buffer_pos = 0;
|
||||
dev->dac[1].buffer_pos_end = 0;
|
||||
dev->dac[1].prev_out_l = 0;
|
||||
dev->dac[1].prev_out_r = 0;
|
||||
dac2start = 1;
|
||||
es137x_fetch(dev, 1);
|
||||
}
|
||||
// audiopci_log("INTCTRL 0x%02X\n", val & 0xff);
|
||||
dev->int_ctrl = val;
|
||||
gameport_remap(dev->gameport, 0x200 | ((val & 0x03000000) >> 21));
|
||||
es1370_calc_sample_rate(dev);
|
||||
if (dac1start)
|
||||
dev->step_synth = dev->interp_step_synth;
|
||||
if (dac2start)
|
||||
dev->step_pcm = dev->interp_step;
|
||||
break;
|
||||
}
|
||||
if (!(dev->int_ctrl & INT_DAC2_EN) && (val & INT_DAC2_EN)) {
|
||||
dev->dac[1].addr = dev->dac[1].addr_latch;
|
||||
dev->dac[1].buffer_pos = 0;
|
||||
dev->dac[1].buffer_pos_end = 0;
|
||||
dev->dac[1].prev_out_l = 0;
|
||||
dev->dac[1].prev_out_r = 0;
|
||||
dac2start = 1;
|
||||
es137x_fetch(dev, 1);
|
||||
}
|
||||
//pclog("INTCTRL 0x%02X\n", val & 0xff);
|
||||
dev->int_ctrl = val;
|
||||
gameport_remap(dev->gameport, 0x200 | ((val & 0x03000000) >> 21));
|
||||
es1370_calc_sample_rate(dev);
|
||||
if (dac1start)
|
||||
dev->step_synth = dev->interp_step_synth;
|
||||
if (dac2start)
|
||||
dev->step_pcm = dev->interp_step;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Interrupt/Chip Select Status Register, Address 04H
|
||||
Addressable as longword only */
|
||||
@@ -1413,7 +1419,7 @@ es137x_outl(uint16_t port, uint32_t val, void *priv)
|
||||
audiopci_log("[W] STATUS = %08X\n", val);
|
||||
if (dev->type >= AUDIOPCI_CT5880)
|
||||
dev->int_status = (dev->int_status & 0xd208ffff) | (val & 0x2df70000);
|
||||
else if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
else if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
dev->int_status = (dev->int_status & 0xff08ffff) | (val & 0x00f70000);
|
||||
break;
|
||||
|
||||
@@ -1426,8 +1432,7 @@ es137x_outl(uint16_t port, uint32_t val, void *priv)
|
||||
/* Sample Rate Converter Interface Register, Address 10H
|
||||
Addressable as longword only */
|
||||
case 0x10:
|
||||
if (dev->type == AUDIOPCI_ES1370)
|
||||
{
|
||||
if (dev->type == AUDIOPCI_ES1370) {
|
||||
dev->akm_codec.registers[(val >> 8) & 0xFF] = val & 0xFF;
|
||||
if ((val >> 8) == 0x16 && !(val & 1))
|
||||
akm4531_reset(dev);
|
||||
@@ -1876,28 +1881,28 @@ es1370_pci_read(int func, int addr, void *priv)
|
||||
return 0x00;
|
||||
|
||||
switch (addr) {
|
||||
case 0x00: /* Vendor ID */
|
||||
case 0x00: /* Vendor ID */
|
||||
return 0x74; /* Ensoniq */
|
||||
case 0x01:
|
||||
return 0x12;
|
||||
|
||||
case 0x02: /* Device ID */
|
||||
return 0x00; /* ES1370 */
|
||||
case 0x02: /* Device ID */
|
||||
return dev->type >> 16; /* ES1370 */
|
||||
case 0x03:
|
||||
return 0x50;
|
||||
return dev->type >> 24;
|
||||
|
||||
case 0x04: /* Command TODO */
|
||||
return dev->pci_command;
|
||||
case 0x05:
|
||||
return dev->pci_serr;
|
||||
|
||||
case 0x06: /* Status TODO */
|
||||
case 0x06: /* Status TODO */
|
||||
return 0x10; /* Supports ACPI */
|
||||
case 0x07:
|
||||
return 0x00;
|
||||
|
||||
case 0x08: /* Class Code & Revision ID */
|
||||
return 0x00; /* Revision ID - 0x00 is actual Ensoniq-branded ES1370 */
|
||||
case 0x08: /* Class Code & Revision ID */
|
||||
return dev->type >> 8; /* Revision ID - 0x00 is actual Ensoniq-branded ES1370 */
|
||||
case 0x09:
|
||||
return 0x00; /* Multimedia audio device */
|
||||
case 0x0a:
|
||||
@@ -1910,7 +1915,7 @@ es1370_pci_read(int func, int addr, void *priv)
|
||||
// case 0x0e: /* Header Type TODO */
|
||||
// case 0x0f: /* BIST TODO */
|
||||
|
||||
case 0x10: /* Base Address TODO */
|
||||
case 0x10: /* Base Address TODO */
|
||||
return 0x01 | (dev->base_addr & 0xc0); /* memBaseAddr */
|
||||
case 0x11:
|
||||
return dev->base_addr >> 8;
|
||||
@@ -1919,14 +1924,8 @@ es1370_pci_read(int func, int addr, void *priv)
|
||||
case 0x13:
|
||||
return dev->base_addr >> 24;
|
||||
|
||||
case 0x2c:
|
||||
return 0x42; /* Subsystem vendor ID */
|
||||
case 0x2d:
|
||||
return 0x49;
|
||||
case 0x2e:
|
||||
return 0x4c; /* Subsystem product ID */
|
||||
case 0x2f:
|
||||
return 0x4c;
|
||||
case 0x2c ... 0x2f:
|
||||
return dev->subsys_id[addr & 3]; /* Subsystem vendor ID */
|
||||
|
||||
#if 0
|
||||
case 0x34: // TODO
|
||||
@@ -2033,7 +2032,7 @@ es1371_pci_read(int func, int addr, void *priv)
|
||||
return 0x80; /* Maximum latency */
|
||||
|
||||
case 0x40:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
return dev->subsys_lock;
|
||||
break;
|
||||
|
||||
@@ -2164,7 +2163,7 @@ es1371_pci_write(int func, int addr, uint8_t val, void *priv)
|
||||
break;
|
||||
|
||||
case 0x40:
|
||||
if (dev->type >= AUDIOPCI_ES1373 && dev->type < AUDIOPCI_ES1370)
|
||||
if ((dev->type >= AUDIOPCI_ES1373) && (dev->type != AUDIOPCI_ES1370))
|
||||
dev->subsys_lock = val;
|
||||
break;
|
||||
|
||||
@@ -2387,9 +2386,8 @@ es137x_poll(void *priv)
|
||||
es137x_update(dev);
|
||||
|
||||
if (dev->int_ctrl & INT_DAC1_EN) {
|
||||
if (((dev->type >= AUDIOPCI_ES1373) && (dev->int_ctrl & INT_DAC1_BYPASS)) || dev->type == AUDIOPCI_ES1370) {
|
||||
if (dev->calc_sample_rate_synth != 44100 && dev->type == AUDIOPCI_ES1370)
|
||||
{
|
||||
if (((dev->type >= AUDIOPCI_ES1373) && (dev->int_ctrl & INT_DAC1_BYPASS)) || (dev->type == AUDIOPCI_ES1370)) {
|
||||
if ((dev->calc_sample_rate_synth != 44100) && (dev->type == AUDIOPCI_ES1370)) {
|
||||
if ((dev->dac[0].buffer_pos - dev->dac[0].buffer_pos_end) >= 0 && dev->step_synth >= dev->interp_step_synth)
|
||||
es137x_fetch(dev, 0);
|
||||
|
||||
@@ -2446,9 +2444,8 @@ dac0_count:
|
||||
}
|
||||
|
||||
if (dev->int_ctrl & INT_DAC2_EN) {
|
||||
if (((dev->type >= AUDIOPCI_ES1373) && (dev->int_ctrl & INT_DAC2_BYPASS)) || dev->type == AUDIOPCI_ES1370) {
|
||||
if (dev->calc_sample_rate != 44100 && dev->type == AUDIOPCI_ES1370)
|
||||
{
|
||||
if (((dev->type >= AUDIOPCI_ES1373) && (dev->int_ctrl & INT_DAC2_BYPASS)) || (dev->type == AUDIOPCI_ES1370)) {
|
||||
if ((dev->calc_sample_rate != 44100) && (dev->type == AUDIOPCI_ES1370)) {
|
||||
if ((dev->dac[1].buffer_pos - dev->dac[1].buffer_pos_end) >= 0 && dev->step_pcm >= dev->interp_step)
|
||||
es137x_fetch(dev, 1);
|
||||
|
||||
@@ -2619,6 +2616,7 @@ es1370_init(const device_t *info)
|
||||
{
|
||||
es137x_t *dev = malloc(sizeof(es137x_t));
|
||||
memset(dev, 0x00, sizeof(es137x_t));
|
||||
dev->type = info->local;
|
||||
|
||||
if (device_get_config_int("receive_input"))
|
||||
midi_in_handler(1, es137x_input_msg, es137x_input_sysex, dev);
|
||||
@@ -2640,19 +2638,17 @@ es1370_init(const device_t *info)
|
||||
dev->dac[1].vol_l = 1 << 12;
|
||||
dev->dac[1].vol_r = 1 << 12;
|
||||
|
||||
dev->pcm_vol_l = 1 << 15;
|
||||
dev->pcm_vol_r = 1 << 15;
|
||||
dev->pcm_vol_l = 1 << 15;
|
||||
dev->pcm_vol_r = 1 << 15;
|
||||
dev->master_vol_l = 1 << 15;
|
||||
dev->master_vol_r = 1 << 15;
|
||||
|
||||
dev->type = AUDIOPCI_ES1370;
|
||||
|
||||
es137x_reset(dev);
|
||||
|
||||
es137x_speed_changed(dev);
|
||||
|
||||
for (int i = 0; i < 0x20; i++) {
|
||||
double attn = (12.0 - (i * 2.0));
|
||||
double attn = (12.0 - (i * 2.0));
|
||||
akm4531_gain_2dbstep_5bits[i] = pow(10, attn / 10.) * 32767.0;
|
||||
}
|
||||
|
||||
@@ -2706,11 +2702,11 @@ es137x_speed_changed(void *priv)
|
||||
{
|
||||
es137x_t *dev = (es137x_t *) priv;
|
||||
|
||||
dev->dac[1].latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / (double) (dev->type == AUDIOPCI_ES1370 ? WT_FREQ : SOUND_FREQ)));
|
||||
dev->dac[1].latch = (uint64_t) ((double) TIMER_USEC * (1000000.0 / (double) ((dev->type == AUDIOPCI_ES1370) ? WT_FREQ : SOUND_FREQ)));
|
||||
}
|
||||
|
||||
static const device_config_t es1370_config[] = {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
{
|
||||
.name = "receive_input",
|
||||
.description = "Receive input (MIDI)",
|
||||
@@ -2719,11 +2715,11 @@ static const device_config_t es1370_config[] = {
|
||||
.default_int = 1
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_config_t es1371_config[] = {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
{
|
||||
.name = "codec",
|
||||
.description = "Codec",
|
||||
@@ -2749,11 +2745,11 @@ static const device_config_t es1371_config[] = {
|
||||
.default_int = 1
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_config_t es1373_config[] = {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
{
|
||||
.name = "codec",
|
||||
.description = "Codec",
|
||||
@@ -2783,11 +2779,11 @@ static const device_config_t es1373_config[] = {
|
||||
.default_int = 1
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_config_t ct5880_config[] = {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
{
|
||||
.name = "codec",
|
||||
.description = "Codec",
|
||||
@@ -2813,11 +2809,11 @@ static const device_config_t ct5880_config[] = {
|
||||
.default_int = 1
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
static const device_config_t es1371_onboard_config[] = {
|
||||
// clang-format off
|
||||
// clang-format off
|
||||
{
|
||||
.name = "receive_input",
|
||||
.description = "Receive MIDI input",
|
||||
@@ -2826,14 +2822,14 @@ static const device_config_t es1371_onboard_config[] = {
|
||||
.default_int = 1
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
// clang-format on
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
const device_t es1370_device = {
|
||||
.name = "Ensoniq AudioPCI (ES1370)",
|
||||
.internal_name = "es1370",
|
||||
.flags = DEVICE_PCI,
|
||||
.local = 0,
|
||||
.local = AUDIOPCI_ES1370,
|
||||
.init = es1370_init,
|
||||
.close = es137x_close,
|
||||
.reset = es137x_reset,
|
||||
|
||||
@@ -144,8 +144,8 @@ sb_log(const char *fmt, ...)
|
||||
static void
|
||||
sb_get_buffer_sb2(int32_t *buffer, int len, void *priv)
|
||||
{
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
const sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
const sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
|
||||
double out_mono;
|
||||
|
||||
sb_dsp_update(&sb->dsp);
|
||||
@@ -154,8 +154,8 @@ sb_get_buffer_sb2(int32_t *buffer, int len, void *priv)
|
||||
cms_update(&sb->cms);
|
||||
|
||||
for (int c = 0; c < len * 2; c += 2) {
|
||||
double out_l = 0.0;
|
||||
double out_r = 0.0;
|
||||
double out_l = 0.0;
|
||||
double out_r = 0.0;
|
||||
|
||||
if (sb->cms_enabled) {
|
||||
out_l += sb->cms.buffer[c];
|
||||
@@ -195,15 +195,15 @@ sb_get_buffer_sb2(int32_t *buffer, int len, void *priv)
|
||||
static void
|
||||
sb_get_music_buffer_sb2(int32_t *buffer, int 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;
|
||||
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 (int c = 0; c < len * 2; c += 2) {
|
||||
double out_l = 0.0;
|
||||
double out_r = 0.0;
|
||||
double out_l = 0.0;
|
||||
double out_r = 0.0;
|
||||
|
||||
const double out_mono = ((double) opl_buf[c]) * 0.7171630859375;
|
||||
|
||||
@@ -341,8 +341,8 @@ sbpro_filter_cd_audio(int channel, double *buffer, void *priv)
|
||||
static void
|
||||
sb_get_buffer_sb16_awe32(int32_t *buffer, int len, void *priv)
|
||||
{
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
|
||||
double bass_treble;
|
||||
|
||||
sb_dsp_update(&sb->dsp);
|
||||
@@ -415,7 +415,7 @@ sb_get_music_buffer_sb16_awe32(int32_t *buffer, const int len, void *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;
|
||||
const int32_t *opl_buf = NULL;
|
||||
|
||||
if (sb->opl_enabled)
|
||||
opl_buf = sb->opl.update(sb->opl.priv);
|
||||
@@ -508,7 +508,6 @@ sb_get_music_buffer_sb16_awe32(int32_t *buffer, const int len, void *priv)
|
||||
sb->opl.reset_buffer(sb->opl.priv);
|
||||
}
|
||||
|
||||
// TODO: Goldfinch
|
||||
static void
|
||||
sb_get_wavetable_buffer_goldfinch(int32_t *buffer, const int len, void *priv)
|
||||
{
|
||||
@@ -533,8 +532,8 @@ sb_get_wavetable_buffer_goldfinch(int32_t *buffer, const int len, void *priv)
|
||||
static void
|
||||
sb_get_wavetable_buffer_sb16_awe32(int32_t *buffer, const int len, void *priv)
|
||||
{
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
const sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
|
||||
double bass_treble;
|
||||
|
||||
emu8k_update(&sb->emu8k);
|
||||
@@ -1215,7 +1214,7 @@ 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;
|
||||
uint8_t ret = 0xff;
|
||||
|
||||
sb_log("sb_ct1745: received register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
|
||||
|
||||
@@ -1343,9 +1342,9 @@ sb_ct1745_mixer_read(uint16_t addr, void *priv)
|
||||
const uint8_t temp = ((sb->dsp.sb_irq8) ? 1 : 0) | ((sb->dsp.sb_irq16) ? 2 : 0) |
|
||||
((sb->dsp.sb_irq401) ? 4 : 0);
|
||||
if (sb->dsp.sb_type >= SBAWE32)
|
||||
ret = temp | 0x80;
|
||||
ret = temp | 0x80;
|
||||
else
|
||||
ret = temp | 0x40;
|
||||
ret = temp | 0x40;
|
||||
break;
|
||||
|
||||
case 0x83:
|
||||
@@ -1371,22 +1370,22 @@ sb_ct1745_mixer_read(uint16_t addr, void *priv)
|
||||
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. */
|
||||
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. */
|
||||
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)
|
||||
ret = mixer->regs[mixer->index];
|
||||
break;
|
||||
@@ -1416,7 +1415,7 @@ sb_ct1745_mixer_reset(sb_t *sb)
|
||||
static void
|
||||
ess_base_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
sb_t * ess = (sb_t *) priv;
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
|
||||
switch (addr & 0x000f) {
|
||||
case 0x0002:
|
||||
@@ -1435,7 +1434,7 @@ ess_base_write(uint16_t addr, uint8_t val, void *priv)
|
||||
static uint8_t
|
||||
ess_base_read(uint16_t addr, void *priv)
|
||||
{
|
||||
sb_t * ess = (sb_t *) priv;
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
|
||||
switch (addr & 0x000f) {
|
||||
case 0x0002:
|
||||
@@ -1462,7 +1461,7 @@ ess_base_read(uint16_t addr, void *priv)
|
||||
static void
|
||||
ess_fm_midi_write(uint16_t addr, uint8_t val, void *priv)
|
||||
{
|
||||
sb_t * ess = (sb_t *) priv;
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
|
||||
ess->dsp.activity &= 0x7f;
|
||||
}
|
||||
@@ -1470,7 +1469,7 @@ ess_fm_midi_write(uint16_t addr, uint8_t val, void *priv)
|
||||
static uint8_t
|
||||
ess_fm_midi_read(uint16_t addr, void *priv)
|
||||
{
|
||||
sb_t * ess = (sb_t *) priv;
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
|
||||
ess->dsp.activity &= 0x7f;
|
||||
|
||||
@@ -1548,8 +1547,8 @@ ess_mixer_write(uint16_t addr, uint8_t val, void *priv)
|
||||
break;
|
||||
|
||||
case 0x0E:
|
||||
mixer->output_filter = !(mixer->regs[0xE] & 0x20);
|
||||
mixer->stereo = mixer->regs[0xE] & 2;
|
||||
mixer->output_filter = !(mixer->regs[0xE] & 0x20);
|
||||
mixer->stereo = mixer->regs[0xE] & 2;
|
||||
sb_dsp_set_stereo(&ess->dsp, val & 2);
|
||||
break;
|
||||
|
||||
@@ -1586,12 +1585,18 @@ ess_mixer_write(uint16_t addr, uint8_t val, void *priv)
|
||||
/* 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 0x30:
|
||||
case 0x32:
|
||||
case 0x36:
|
||||
case 0x38:
|
||||
case 0x3e:
|
||||
mixer->regs[mixer->index - 0x10] = (val & 0xee);
|
||||
break;
|
||||
|
||||
case 0x00: case 0x04: case 0x3a: case 0x3c:
|
||||
case 0x00:
|
||||
case 0x04:
|
||||
case 0x3a:
|
||||
case 0x3c:
|
||||
break;
|
||||
|
||||
case 0x64:
|
||||
@@ -1625,43 +1630,44 @@ ess_mixer_write(uint16_t addr, uint8_t val, void *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;
|
||||
}
|
||||
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(addr, 0x0002,
|
||||
ess_fm_midi_read, NULL, NULL,
|
||||
@@ -1696,85 +1702,86 @@ ess_mixer_write(uint16_t addr, uint8_t val, void *priv)
|
||||
uint8_t
|
||||
ess_mixer_read(uint16_t addr, void *priv)
|
||||
{
|
||||
const sb_t * ess = (sb_t *) priv;
|
||||
const 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 0x32:
|
||||
case 0x36:
|
||||
case 0x38:
|
||||
case 0x3e:
|
||||
ret = mixer->regs[mixer->index];
|
||||
break;
|
||||
|
||||
case 0x04:
|
||||
case 0x22:
|
||||
case 0x26:
|
||||
case 0x28:
|
||||
case 0x2e:
|
||||
ret = mixer->regs[mixer->index] | 0x11;
|
||||
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_ES1688)
|
||||
else
|
||||
switch (mixer->index) {
|
||||
case 0x00:
|
||||
case 0x0a:
|
||||
case 0x0c:
|
||||
case 0x0e:
|
||||
case 0x14:
|
||||
case 0x1a:
|
||||
case 0x02:
|
||||
case 0x06:
|
||||
case 0x30:
|
||||
case 0x32:
|
||||
case 0x36:
|
||||
case 0x38:
|
||||
case 0x3e:
|
||||
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;
|
||||
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;
|
||||
case 0x04:
|
||||
case 0x22:
|
||||
case 0x26:
|
||||
case 0x28:
|
||||
case 0x2e:
|
||||
ret = mixer->regs[mixer->index] | 0x11;
|
||||
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_ES1688)
|
||||
ret = (mixer->regs[mixer->index] & 0xf7) | 0x20;
|
||||
else
|
||||
ret = 0x00;
|
||||
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;
|
||||
|
||||
default:
|
||||
sb_log("ess: Unknown mixer register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
Real ES688: Always 0x00;
|
||||
Real ES1688: Bit 2 always clear.
|
||||
*/
|
||||
case 0x40:
|
||||
if (ess->dsp.sb_subtype > SB_SUBTYPE_ESS_ES1688)
|
||||
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;
|
||||
|
||||
/*
|
||||
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_ES1688)
|
||||
ret = (mixer->regs[mixer->index] & 0xf7) | 0x20;
|
||||
else
|
||||
ret = 0x00;
|
||||
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);
|
||||
|
||||
@@ -1854,8 +1861,8 @@ sb_mcv_feedb(void *priv)
|
||||
static uint8_t
|
||||
sb_pro_mcv_read(int port, void *priv)
|
||||
{
|
||||
const sb_t *sb = (sb_t *) priv;
|
||||
uint8_t ret = sb->pos_regs[port & 7];
|
||||
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);
|
||||
|
||||
@@ -1925,8 +1932,8 @@ sb_pro_mcv_write(int port, uint8_t val, void *priv)
|
||||
static uint8_t
|
||||
sb_16_reply_mca_read(int port, void *priv)
|
||||
{
|
||||
const sb_t *sb = (sb_t *) priv;
|
||||
uint8_t ret = sb->pos_regs[port & 7];
|
||||
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);
|
||||
|
||||
@@ -2153,7 +2160,7 @@ sb_16_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void
|
||||
mpu401_change_addr(sb->mpu, 0);
|
||||
|
||||
if (config->activate) {
|
||||
uint8_t val = config->irq[0].irq;
|
||||
uint8_t val = config->irq[0].irq;
|
||||
|
||||
addr = config->io[0].base;
|
||||
if (addr != ISAPNP_IO_DISABLED) {
|
||||
@@ -2225,7 +2232,7 @@ sb_16_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void
|
||||
static void
|
||||
sb_vibra16_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, void *priv)
|
||||
{
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
sb_t *sb = (sb_t *) priv;
|
||||
|
||||
switch (ld) {
|
||||
case 0: /* Audio */
|
||||
@@ -2248,7 +2255,7 @@ goldfinch_pnp_config_changed(const uint8_t ld, isapnp_device_config_t *config, v
|
||||
break;
|
||||
|
||||
case 0: /* WaveTable */
|
||||
emu8k_change_addr(&goldfinch->emu8k, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
|
||||
emu8k_change_addr(&goldfinch->emu8k, (config->activate && (config->io[0].base != ISAPNP_IO_DISABLED)) ? config->io[0].base : 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2513,7 +2520,7 @@ ess_x688_mca_read(const int port, void *priv)
|
||||
static void
|
||||
ess_soundpiper_mca_write(const int port, const uint8_t val, void *priv)
|
||||
{
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
|
||||
if (port < 0x102)
|
||||
return;
|
||||
@@ -2676,7 +2683,7 @@ ess_soundpiper_mca_write(const int port, const uint8_t val, void *priv)
|
||||
static void
|
||||
ess_chipchat_mca_write(int port, uint8_t val, void *priv)
|
||||
{
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
sb_t *ess = (sb_t *) priv;
|
||||
|
||||
if (port < 0x102)
|
||||
return;
|
||||
@@ -2811,7 +2818,7 @@ sb_1_init(UNUSED(const device_t *info))
|
||||
2x0 to 2x3 -> CMS chip
|
||||
2x6, 2xA, 2xC, 2xE -> DSP chip
|
||||
2x8, 2x9, 388 and 389 FM chip */
|
||||
sb_t * sb = malloc(sizeof(sb_t));
|
||||
sb_t *sb = malloc(sizeof(sb_t));
|
||||
const uint16_t addr = device_get_config_hex16("base");
|
||||
memset(sb, 0, sizeof(sb_t));
|
||||
|
||||
@@ -2862,7 +2869,7 @@ sb_15_init(UNUSED(const device_t *info))
|
||||
2x0 to 2x3 -> CMS chip
|
||||
2x6, 2xA, 2xC, 2xE -> DSP chip
|
||||
2x8, 2x9, 388 and 389 FM chip */
|
||||
sb_t * sb = malloc(sizeof(sb_t));
|
||||
sb_t *sb = malloc(sizeof(sb_t));
|
||||
const uint16_t addr = device_get_config_hex16("base");
|
||||
memset(sb, 0, sizeof(sb_t));
|
||||
|
||||
@@ -3223,7 +3230,7 @@ sb_pro_compat_init(UNUSED(const device_t *info))
|
||||
static void *
|
||||
sb_16_init(UNUSED(const device_t *info))
|
||||
{
|
||||
sb_t *sb = malloc(sizeof(sb_t));
|
||||
sb_t *sb = malloc(sizeof(sb_t));
|
||||
const uint16_t addr = device_get_config_hex16("base");
|
||||
const uint16_t mpu_addr = device_get_config_hex16("base401");
|
||||
|
||||
@@ -3281,7 +3288,7 @@ sb_16_init(UNUSED(const device_t *info))
|
||||
if (device_get_config_int("receive_input"))
|
||||
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
|
||||
|
||||
sb->gameport = gameport_add(&gameport_pnp_device);
|
||||
sb->gameport = gameport_add(&gameport_pnp_device);
|
||||
sb->gameport_addr = 0x200;
|
||||
gameport_remap(sb->gameport, sb->gameport_addr);
|
||||
|
||||
@@ -3385,7 +3392,7 @@ sb_16_pnp_init(UNUSED(const device_t *info))
|
||||
}
|
||||
|
||||
const char *pnp_rom_file = NULL;
|
||||
uint16_t pnp_rom_len = 512;
|
||||
uint16_t pnp_rom_len = 512;
|
||||
switch (info->local) {
|
||||
case SB_16_PNP_NOIDE:
|
||||
pnp_rom_file = PNP_ROM_SB_16_PNP_NOIDE;
|
||||
@@ -3447,7 +3454,6 @@ sb_vibra16xv_available(void)
|
||||
return rom_present(PNP_ROM_SB_VIBRA16XV);
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
sb_vibra16_pnp_init(UNUSED(const device_t *info))
|
||||
{
|
||||
@@ -3482,7 +3488,7 @@ sb_vibra16_pnp_init(UNUSED(const device_t *info))
|
||||
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
|
||||
|
||||
switch (info->local) {
|
||||
case SB_VIBRA16C: /* CTL7001 */
|
||||
case SB_VIBRA16C: /* CTL7001 */
|
||||
case SB_VIBRA16CL: /* CTL7002 */
|
||||
sb->gameport = gameport_add(&gameport_pnp_device);
|
||||
break;
|
||||
@@ -3563,7 +3569,7 @@ sb_16_compat_init(const device_t *info)
|
||||
sb_dsp_setdma16_enabled(&sb->dsp, 1);
|
||||
sb_ct1745_mixer_reset(sb);
|
||||
|
||||
sb->opl_enabled = 1;
|
||||
sb->opl_enabled = 1;
|
||||
sb->mixer_enabled = 1;
|
||||
sound_add_handler(sb_get_buffer_sb16_awe32, sb);
|
||||
music_add_handler(sb_get_music_buffer_sb16_awe32, sb);
|
||||
@@ -3573,7 +3579,7 @@ sb_16_compat_init(const device_t *info)
|
||||
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 = gameport_add(&gameport_pnp_device);
|
||||
sb->gameport_addr = 0x200;
|
||||
gameport_remap(sb->gameport, sb->gameport_addr);
|
||||
|
||||
@@ -3694,7 +3700,7 @@ sb_awe32_init(UNUSED(const device_t *info))
|
||||
if (device_get_config_int("receive_input"))
|
||||
midi_in_handler(1, sb_dsp_input_msg, sb_dsp_input_sysex, &sb->dsp);
|
||||
|
||||
sb->gameport = gameport_add(&gameport_pnp_device);
|
||||
sb->gameport = gameport_add(&gameport_pnp_device);
|
||||
sb->gameport_addr = 0x200;
|
||||
gameport_remap(sb->gameport, sb->gameport_addr);
|
||||
|
||||
@@ -3887,7 +3893,7 @@ sb_awe32_pnp_init(const device_t *info)
|
||||
static void *
|
||||
ess_x688_init(UNUSED(const device_t *info))
|
||||
{
|
||||
sb_t *ess = calloc(sizeof(sb_t), 1);
|
||||
sb_t *ess = 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;
|
||||
@@ -4001,7 +4007,7 @@ ess_1688_968_pnp_available(void)
|
||||
static void *
|
||||
ess_x688_pnp_init(UNUSED(const device_t *info))
|
||||
{
|
||||
sb_t *ess = calloc(sizeof(sb_t), 1);
|
||||
sb_t *ess = calloc(sizeof(sb_t), 1);
|
||||
|
||||
ess->pnp = 1 + (int) info->local;
|
||||
|
||||
@@ -4012,7 +4018,7 @@ ess_x688_pnp_init(UNUSED(const device_t *info))
|
||||
sb_dsp_setdma16_supported(&ess->dsp, 0);
|
||||
ess_mixer_reset(ess);
|
||||
|
||||
ess->mixer_enabled = 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);
|
||||
@@ -4098,7 +4104,7 @@ ess_x688_mca_init(UNUSED(const device_t *info))
|
||||
sb_dsp_setdma16_supported(&ess->dsp, 0);
|
||||
ess_mixer_reset(ess);
|
||||
|
||||
ess->mixer_enabled = 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);
|
||||
@@ -5584,7 +5590,6 @@ static const device_config_t ess_688_config[] = {
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static const device_config_t ess_1688_config[] = {
|
||||
{
|
||||
@@ -5722,7 +5727,6 @@ static const device_config_t ess_1688_config[] = {
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static const device_config_t ess_688_pnp_config[] = {
|
||||
{
|
||||
@@ -5734,7 +5738,6 @@ static const device_config_t ess_688_pnp_config[] = {
|
||||
},
|
||||
{ .name = "", .description = "", .type = CONFIG_END }
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
static const device_config_t ess_1688_pnp_config[] = {
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user