Fallback to old MPU behaviour on SB cards. Fixes SB16/AWE32 initialisation on

Windows 3.1.
This commit is contained in:
SarahW 2020-04-11 14:47:19 +01:00
commit 5e437fc736
4 changed files with 22 additions and 9 deletions

View file

@ -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);

View file

@ -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);
}

View file

@ -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);

View file

@ -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;