From dfa0ec6be80dab9dc800724dd988d9c9584eeae9 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Mon, 4 Mar 2024 02:00:07 +0600 Subject: [PATCH] Implement ESS identification mixer register --- src/sound/snd_ess.c | 21 +++++++++++++++++++-- src/sound/snd_sb_dsp.c | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/sound/snd_ess.c b/src/sound/snd_ess.c index f0f1b5ec7..9347a755e 100644 --- a/src/sound/snd_ess.c +++ b/src/sound/snd_ess.c @@ -76,6 +76,9 @@ typedef struct ess_mixer_t { uint8_t index; uint8_t regs[256]; + + uint8_t ess_id_str[4]; + uint8_t ess_id_str_pos : 2; } ess_mixer_t; typedef struct ess_t { @@ -128,6 +131,8 @@ ess_mixer_write(uint16_t addr, uint8_t val, void *priv) if (!(addr & 1)) { mixer->index = val; mixer->regs[0x01] = val; + if (val == 0x40) + mixer->ess_id_str_pos = 0; } else { if (mixer->index == 0) { /* Reset */ @@ -218,8 +223,8 @@ ess_mixer_write(uint16_t addr, uint8_t val, void *priv) uint8_t ess_mixer_read(uint16_t addr, void *priv) { - const ess_t *ess = (ess_t *) priv; - const ess_mixer_t *mixer = &ess->mixer_sbpro; + ess_t *ess = (ess_t *) priv; + ess_mixer_t *mixer = &ess->mixer_sbpro; if (!(addr & 1)) return mixer->index; @@ -242,6 +247,11 @@ ess_mixer_read(uint16_t addr, void *priv) case 0x38: return mixer->regs[mixer->index]; + case 0x40: + { + return mixer->ess_id_str[mixer->ess_id_str_pos++]; + } + default: //sb_log("ess: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]); break; @@ -391,6 +401,13 @@ ess_1688_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, &ess->dsp); + { + ess->mixer_sbpro.ess_id_str[0] = 0x16; + ess->mixer_sbpro.ess_id_str[1] = 0x88; + ess->mixer_sbpro.ess_id_str[2] = (addr >> 8) & 0xff; + ess->mixer_sbpro.ess_id_str[3] = addr & 0xff; + } + return ess; } diff --git a/src/sound/snd_sb_dsp.c b/src/sound/snd_sb_dsp.c index 58131515d..45f8440a2 100644 --- a/src/sound/snd_sb_dsp.c +++ b/src/sound/snd_sb_dsp.c @@ -900,6 +900,9 @@ sb_exec_command(sb_dsp_t *dsp) case 0x10: /* 8-bit direct mode */ sb_dsp_update(dsp); dsp->sbdat = dsp->sbdatl = dsp->sbdatr = (dsp->sb_data[0] ^ 0x80) << 8; + // FIXME: What does the ESS AudioDrive do to its filter/sample rate divider registers when emulating this Sound Blaster command? + ESSreg(0xA1) = 128 - (397700 / 22050); + ESSreg(0xA2) = 256 - (7160000 / (82 * ((4 * 22050) / 10))); break; case 0x14: /* 8-bit single cycle DMA output */ sb_start_dma(dsp, 1, 0, 0, dsp->sb_data[0] + (dsp->sb_data[1] << 8));