Merge pull request #5304 from 86Box/tc1995

ESS/SB changes of the day (March 8th, 2025)
This commit is contained in:
Miran Grča
2025-03-08 19:40:53 +01:00
committed by GitHub
2 changed files with 59 additions and 56 deletions

View File

@@ -1335,7 +1335,7 @@ sb_ct1745_mixer_read(uint16_t addr, void *priv)
break;
case 0x82:
; /* Empty statement to make compilers happy about the following variable declaration. */
/* 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. */
@@ -1727,6 +1727,7 @@ ess_mixer_read(uint16_t addr, void *priv)
case 0x32:
case 0x36:
case 0x38:
case 0x3a:
case 0x3e:
ret = mixer->regs[mixer->index];
break;
@@ -2593,10 +2594,10 @@ ess_soundpiper_mca_write(const int port, const uint8_t val, void *priv)
ess->dsp.sb_addr = 0x0000;
break;
case 0x08:
ess->dsp.sb_addr = 0x0240;
ess->dsp.sb_addr = 0x0220;
break;
case 0x0c:
ess->dsp.sb_addr = 0x0220;
ess->dsp.sb_addr = 0x0240;
break;
}
@@ -2750,64 +2751,59 @@ ess_chipchat_mca_write(int port, uint8_t val, void *priv)
ess->pos_regs[port & 7] = val;
if (ess->pos_regs[2] & 1) {
ess->dsp.sb_addr = (ess->pos_regs[2] == 0x51) ? 0x0220 : 0x0000;
if (ess->pos_regs[2] & 0x01) {
ess->dsp.sb_addr = 0x0220;
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,
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, 0x0004,
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);
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, 0x0004,
ess_mixer_read, NULL, NULL,
ess_mixer_write, NULL, NULL,
ess);
io_sethandler(ess->dsp.sb_addr + 2, 0x0004,
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[2] == 0x51) ? 0x0330 : 0);
if (ess->pos_regs[2] == 0x51)
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[2] == 0x51) ? 0x200 : 0);
}
gameport_remap(ess->gameport, 0x0200);
if (ess->pos_regs[2] == 0x51) {
sb_dsp_setirq(&ess->dsp, 7);
mpu401_setirq(ess->mpu, 7);

View File

@@ -388,6 +388,7 @@ sb_update_status(sb_dsp_t *dsp, int bit, int set)
{
int masked = 0;
sb_dsp_log("SBIRQ8=%d, irqnum=%d, bit=%x, set=%x.\n", dsp->sb_irq8, dsp->sb_irqnum, bit, set);
if (dsp->sb_irq8 || dsp->sb_irq16)
return;
@@ -423,6 +424,7 @@ sb_update_status(sb_dsp_t *dsp, int bit, int set)
}
}
sb_dsp_log("Masked=%02x.\n", masked);
if (set && !masked)
dsp->irq_update(dsp->irq_priv, 1);
else if (!set)
@@ -1039,6 +1041,8 @@ sb_ess_write_reg(sb_dsp_t *dsp, const uint8_t reg, uint8_t data)
{
uint8_t chg;
sb_dsp_log("ESS Write reg=%02x, val=%02x.\n", reg, data);
switch (reg) {
case 0xA1: /* Extended Mode Sample Rate Generator */
{
@@ -1110,6 +1114,7 @@ sb_ess_write_reg(sb_dsp_t *dsp, const uint8_t reg, uint8_t data)
dsp->sb_irqnum = 10;
break;
}
sb_dsp_log("Legacy Audio IRQ control=%d.\n", dsp->sb_irqnum);
sb_ess_update_irq_drq_readback_regs(dsp, false);
break;
case 0xB2: /* DRQ Control */
@@ -1131,6 +1136,7 @@ sb_ess_write_reg(sb_dsp_t *dsp, const uint8_t reg, uint8_t data)
dsp->sb_8_dmanum = 3;
break;
}
sb_dsp_log("Legacy Audio DRQ control=%d, chg=%02x.\n", dsp->sb_8_dmanum, chg);
sb_ess_update_irq_drq_readback_regs(dsp, false);
if (chg & 0x40)
sb_ess_update_dma_status(dsp);
@@ -1876,12 +1882,12 @@ sb_write(uint16_t addr, uint8_t val, void *priv)
{
sb_dsp_t *dsp = (sb_dsp_t *) priv;
sb_dsp_log("[%04X:%08X] DSP: [W] %04X = %02X\n", CS, cpu_state.pc, addr, val);
/* Sound Blasters prior to Sound Blaster 16 alias the I/O ports. */
if ((dsp->sb_type < SB16_DSP_404) && (IS_NOT_ESS(dsp) || ((addr & 0xF) != 0xE)))
addr &= 0xfffe;
sb_dsp_log("[%04X:%08X] DSP: [W] %04X = %02X\n", CS, cpu_state.pc, addr, val);
switch (addr & 0xF) {
case 6: /* Reset */
sb_do_reset(dsp, val);
@@ -1962,7 +1968,7 @@ sb_read(uint16_t addr, void *priv)
uint8_t ret = 0x00;
/* Sound Blasters prior to Sound Blaster 16 alias the I/O ports. */
if ((dsp->sb_type < SB16_DSP_404) && (IS_NOT_ESS(dsp) || ((addr & 0xF) != 0xF)))
if ((dsp->sb_type < SB16_DSP_404) && (IS_NOT_ESS(dsp) || ((addr & 0xF) != 0xE)))
/* Exception: ESS AudioDrive does not alias port base+0xf */
addr &= 0xfffe;
@@ -2085,7 +2091,7 @@ sb_read(uint16_t addr, void *priv)
break;
}
sb_dsp_log("[%04X:%08X] DSP: [R] %04X = %02X\n", CS, cpu_state.pc, a, ret);
sb_dsp_log("[%04X:%08X] DSP: [R] %04X = %02X\n", CS, cpu_state.pc, addr, ret);
return ret;
}
@@ -2319,6 +2325,7 @@ pollsb(void *priv)
if (dsp->sb_8_enable && dsp->sb_pausetime < 0 && dsp->sb_8_output) {
sb_dsp_update(dsp);
sb_dsp_log("8-bit format=%02x, pause=%x, length=%d.\n", dsp->sb_8_format, dsp->sb_8_pause, dsp->sb_8_length);
switch (dsp->sb_8_format) {
case 0x00: /* Mono unsigned */
if (!dsp->sb_8_pause) {