From 04494892cc85310a27e4a7de3473bc4d5d2cdeca Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 20 Mar 2021 14:42:13 -0300 Subject: [PATCH] Make the SB16 OPL remappable by ISAPnP --- src/include/86box/snd_sb.h | 2 ++ src/sound/snd_sb.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/include/86box/snd_sb.h b/src/include/86box/snd_sb.h index 221696acc..3bb2a6496 100644 --- a/src/include/86box/snd_sb.h +++ b/src/include/86box/snd_sb.h @@ -126,6 +126,8 @@ typedef struct sb_t int pos; uint8_t pos_regs[8]; + + uint16_t opl_pnp_addr; } sb_t; extern void sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p); diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 6b04254a0..db338f74e 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -86,6 +86,7 @@ static uint8_t sb_16_pnp_rom[] = { 0x47, 0x01, 0x00, 0x03, 0x30, 0x03, 0x30, 0x02, /* I/O 0x300-0x330, decodes 16-bit, 48-byte alignment, 2 addresses */ 0x47, 0x01, 0x88, 0x03, 0x88, 0x03, 0x01, 0x04, /* I/O 0x388, decodes 16-bit, 1-byte alignment, 4 addresses */ 0x38, /* end dependent functions */ + 0x79, 0x00 /* end tag, dummy checksum (filled in by isapnp_add_card) */ }; static uint8_t sb_awe32_pnp_rom[] = { @@ -1131,11 +1132,16 @@ sb_16_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv) opl3_write, NULL, NULL, &sb->opl); io_removehandler(addr + 8, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl); - io_removehandler(0x0388, 0x0004, opl3_read, NULL, NULL, - opl3_write, NULL, NULL, &sb->opl); 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, opl3_read, NULL, NULL, + opl3_write, NULL, NULL, &sb->opl); + } + sb_dsp_setaddr(&sb->dsp, 0); sb_dsp_setirq(&sb->dsp, 0); sb_dsp_setdma8(&sb->dsp, 0); @@ -1161,9 +1167,11 @@ sb_16_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv) mpu401_change_addr(sb->mpu, addr); addr = config->io[2].base; - if (addr != ISAPNP_IO_DISABLED) - io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, + if (addr != ISAPNP_IO_DISABLED) { + sb->opl_pnp_addr = addr; + io_sethandler(addr, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl); + } val = config->irq[0].irq; if (val != ISAPNP_IRQ_DISABLED)