From 5e437fc7364d48fc50190c730685b87d6a324c74 Mon Sep 17 00:00:00 2001 From: SarahW Date: Sat, 11 Apr 2020 14:47:19 +0100 Subject: [PATCH] Fallback to old MPU behaviour on SB cards. Fixes SB16/AWE32 initialisation on Windows 3.1. --- src/sound_azt2316a.c | 2 +- src/sound_mpu401_uart.c | 21 ++++++++++++++++----- src/sound_mpu401_uart.h | 4 +++- src/sound_sb.c | 4 ++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/sound_azt2316a.c b/src/sound_azt2316a.c index b5fda11..da41bce 100644 --- a/src/sound_azt2316a.c +++ b/src/sound_azt2316a.c @@ -1446,7 +1446,7 @@ void *azt_common_init(const int type, char *nvr_filename) io_sethandler(azt2316a->cur_addr+8, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &azt2316a->sb->opl); io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &azt2316a->sb->opl); io_sethandler(azt2316a->cur_addr+4, 0x0002, sb_ct1345_mixer_read, NULL, NULL, sb_ct1345_mixer_write, NULL, NULL, azt2316a->sb); - mpu401_uart_init(&azt2316a->sb->mpu, azt2316a->cur_mpu401_addr, azt2316a->cur_mpu401_irq); + mpu401_uart_init(&azt2316a->sb->mpu, azt2316a->cur_mpu401_addr, azt2316a->cur_mpu401_irq, 1); azt2316a_create_config_word(azt2316a); // recreate even if we have read it from EEPROM, because we have some overrides (CD interfaces always off, etc) sound_add_handler(azt2316a_get_buffer, azt2316a); diff --git a/src/sound_mpu401_uart.c b/src/sound_mpu401_uart.c index 6ec3614..22cb638 100644 --- a/src/sound_mpu401_uart.c +++ b/src/sound_mpu401_uart.c @@ -31,16 +31,26 @@ static void mpu401_uart_write(uint16_t addr, uint8_t val, void *p) // But actual behaviour is weird. For example, the MPU401 port test in the AZT1605 drivers for Windows NT // want this to return an Ack but the IRQ test in the same driver wants this to raise no interrupts! mpu->rx_data = 0xfe; /*Acknowledge*/ - mpu->status = STATUS_OUTPUT_NOT_READY; mpu->uart_mode = 0; - //mpu401_uart_raise_irq(p); + if (mpu->is_aztech) + mpu->status = STATUS_OUTPUT_NOT_READY; + else + { + mpu->status = 0; + mpu401_uart_raise_irq(p); + } break; case 0x3f: /*Enter UART mode*/ mpu->rx_data = 0xfe; /*Acknowledge*/ - mpu->status = STATUS_OUTPUT_NOT_READY; mpu->uart_mode = 1; - mpu401_uart_raise_irq(p); + if (mpu->is_aztech) + { + mpu->status = STATUS_OUTPUT_NOT_READY; + mpu401_uart_raise_irq(p); + } + else + mpu->status = 0; break; } return; @@ -63,12 +73,13 @@ static uint8_t mpu401_uart_read(uint16_t addr, void *p) return mpu->rx_data; } -void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr, int irq) +void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr, int irq, int is_aztech) { mpu->status = STATUS_INPUT_NOT_READY; mpu->uart_mode = 0; mpu->addr = addr; mpu->irq = irq; + mpu->is_aztech = is_aztech; io_sethandler(addr, 0x0002, mpu401_uart_read, NULL, NULL, mpu401_uart_write, NULL, NULL, mpu); } diff --git a/src/sound_mpu401_uart.h b/src/sound_mpu401_uart.h index b133d80..9634d58 100644 --- a/src/sound_mpu401_uart.h +++ b/src/sound_mpu401_uart.h @@ -9,9 +9,11 @@ typedef struct mpu401_uart_t int uart_mode; uint16_t addr; int irq; + + int is_aztech; } mpu401_uart_t; -void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr, int irq); +void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr, int irq, int is_aztech); void mpu401_uart_update_addr(mpu401_uart_t *mpu, uint16_t addr); void mpu401_uart_update_irq(mpu401_uart_t *mpu, int irq); diff --git a/src/sound_sb.c b/src/sound_sb.c index e2aa7f3..08830d0 100644 --- a/src/sound_sb.c +++ b/src/sound_sb.c @@ -1052,7 +1052,7 @@ void *sb_16_init() io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl); io_sethandler(addr+4, 0x0002, sb_ct1745_mixer_read, NULL, NULL, sb_ct1745_mixer_write, NULL, NULL, sb); sound_add_handler(sb_get_buffer_sb16, sb); - mpu401_uart_init(&sb->mpu, 0x330, -1); + mpu401_uart_init(&sb->mpu, 0x330, -1, 0); return sb; @@ -1082,7 +1082,7 @@ void *sb_awe32_init() io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl); io_sethandler(addr+4, 0x0002, sb_ct1745_mixer_read, NULL, NULL, sb_ct1745_mixer_write, NULL, NULL, sb); sound_add_handler(sb_get_buffer_emu8k, sb); - mpu401_uart_init(&sb->mpu, 0x330, -1); + mpu401_uart_init(&sb->mpu, 0x330, -1, 0); emu8k_init(&sb->emu8k, emu_addr, onboard_ram); return sb;