From 276cdcdff5d4438633c84e0a2b8f4c98190965be Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 20 Nov 2022 20:42:24 +0600 Subject: [PATCH 1/2] OPTiMC: Fix CD audio mixer --- src/sound/snd_ad1848.c | 25 ++++++++++++------------- src/sound/snd_optimc.c | 14 +++++++++++++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/sound/snd_ad1848.c b/src/sound/snd_ad1848.c index 5be928075..de90a3356 100644 --- a/src/sound/snd_ad1848.c +++ b/src/sound/snd_ad1848.c @@ -384,18 +384,17 @@ ad1848_write(uint16_t addr, uint8_t val, void *priv) if (updatefreq) ad1848_updatefreq(ad1848); - if (ad1848->type >= AD1848_TYPE_CS4231) { /* TODO: configure CD volume for CS4248/AD1848 too */ - temp = (ad1848->type == AD1848_TYPE_CS4231) ? 18 : 4; - if (ad1848->regs[temp] & 0x80) - ad1848->cd_vol_l = 0; - else - ad1848->cd_vol_l = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f]; - temp++; - if (ad1848->regs[temp] & 0x80) - ad1848->cd_vol_r = 0; - else - ad1848->cd_vol_r = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f]; - } + temp = (ad1848->type < AD1848_TYPE_CS4231) ? 2 : ((ad1848->type == AD1848_TYPE_CS4231) ? 18 : 4); + if (ad1848->regs[temp] & 0x80) + ad1848->cd_vol_l = 0; + else + ad1848->cd_vol_l = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f]; + temp++; + if (ad1848->regs[temp] & 0x80) + ad1848->cd_vol_r = 0; + else + ad1848->cd_vol_r = ad1848_vols_5bits_aux_gain[ad1848->regs[temp] & 0x1f]; + break; case 2: @@ -600,7 +599,7 @@ ad1848_filter_cd_audio(int channel, double *buffer, void *priv) } void -ad1848_filter_aux2(void* priv, double* out_l, double* out_r) +ad1848_filter_aux2(void *priv, double *out_l, double *out_r) { ad1848_t *ad1848 = (ad1848_t *) priv; diff --git a/src/sound/snd_optimc.c b/src/sound/snd_optimc.c index bac263f0f..5de220ce5 100644 --- a/src/sound/snd_optimc.c +++ b/src/sound/snd_optimc.c @@ -328,6 +328,18 @@ optimc_reg_read(uint16_t addr, void *p) return temp; } +static void +optimc_filter_cd_audio(int channel, double *buffer, void *p) +{ + optimc_t *optimc = (optimc_t*) p; + + if (optimc->cur_wss_enabled) { + ad1848_filter_cd_audio(channel, buffer, p); + } else { + sbpro_filter_cd_audio(channel, buffer, p); + } +} + static void * optimc_init(const device_t *info) { @@ -392,7 +404,7 @@ optimc_init(const device_t *info) io_sethandler(optimc->cur_addr + 4, 0x0002, sb_ct1345_mixer_read, NULL, NULL, sb_ct1345_mixer_write, NULL, NULL, optimc->sb); sound_add_handler(optimc_get_buffer, optimc); - sound_set_cd_audio_filter(sbpro_filter_cd_audio, optimc->sb); + sound_set_cd_audio_filter(optimc_filter_cd_audio, optimc); optimc->mpu = (mpu_t *) malloc(sizeof(mpu_t)); memset(optimc->mpu, 0, sizeof(mpu_t)); From 0beaf278c34d2d2ec1e0868500b9dfbaa761b126 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 20 Nov 2022 20:42:44 +0600 Subject: [PATCH 2/2] OPTiMC: Add non-PnP gameport device --- src/sound/snd_optimc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sound/snd_optimc.c b/src/sound/snd_optimc.c index 5de220ce5..2cf73156b 100644 --- a/src/sound/snd_optimc.c +++ b/src/sound/snd_optimc.c @@ -364,7 +364,7 @@ optimc_init(const device_t *info) optimc->regs[4] = 0x3F; optimc->regs[5] = 0x83; - optimc->gameport = gameport_add(&gameport_device); + optimc->gameport = gameport_add(&gameport_pnp_device); gameport_remap(optimc->gameport, (optimc->regs[0] & 0x1) ? 0x00 : 0x200); if (info->local & 0x100)