diff --git a/src/machine/m_at_socket7.c b/src/machine/m_at_socket7.c index 71c14e096..7564da84a 100644 --- a/src/machine/m_at_socket7.c +++ b/src/machine/m_at_socket7.c @@ -345,8 +345,8 @@ machine_at_cu430hx_gpio_handler(uint8_t write, uint32_t val) uint32_t ret = machine_get_gpio_default(); if (write) { - ret &= (val | 0xffff00ff); - ret = (ret & 0xffffffcf) | (val & 0x0000ff30); + ret &= ((val & 0xffffffcf) | 0xffff0000); + ret |= (val & 0x00000030); if (machine_snd != NULL) switch ((val >> 4) & 0x03) { case 0x00: sb_vibra16c_onboard_relocate_base(0x0220, machine_snd); diff --git a/src/machine/m_at_socket7_3v.c b/src/machine/m_at_socket7_3v.c index 7f090ca51..268baafed 100644 --- a/src/machine/m_at_socket7_3v.c +++ b/src/machine/m_at_socket7_3v.c @@ -289,8 +289,8 @@ machine_at_endeavor_gpio_handler(uint8_t write, uint32_t val) uint32_t ret = machine_get_gpio_default(); if (write) { - ret &= (val | 0xffff00ff); - ret = (ret & 0xffffffcf) | (val & 0x0000ff30); + ret &= ((val & 0xffffffcf) | 0xffff0000); + ret |= (val & 0x00000030); if (machine_snd != NULL) switch ((val >> 4) & 0x03) { case 0x00: sb_vibra16s_onboard_relocate_base(0x0220, machine_snd); diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index 85adc712d..f5aa086d0 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -70,7 +70,6 @@ pc87306_gpio_write(uint16_t port, uint8_t val, void *priv) uint8_t pc87306_gpio_read(uint16_t port, void *priv) { - const pc87306_t *dev = (pc87306_t *) priv; uint32_t ret = machine_handle_gpio(0, 0xffffffff); if (port & 0x0001) @@ -99,11 +98,11 @@ pc87306_gpio_init(pc87306_t *dev) if (dev->gpioba != 0x0000) { if ((dev->regs[0x12]) & 0x10) - io_sethandler(dev->regs[0x0f] << 2, 0x0001, + io_sethandler(dev->gpioba, 0x0001, pc87306_gpio_read, NULL, NULL, pc87306_gpio_write, NULL, NULL, dev); if ((dev->regs[0x12]) & 0x20) - io_sethandler((dev->regs[0x0f] << 2) + 1, 0x0001, + io_sethandler(dev->gpioba + 1, 0x0001, pc87306_gpio_read, NULL, NULL, pc87306_gpio_write, NULL, NULL, dev); } } @@ -254,8 +253,6 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) if ((dev->cur_reg <= 28) && (dev->cur_reg != 8)) { if (dev->cur_reg == 0) val &= 0x5f; - if (((dev->cur_reg == 0x0F) || (dev->cur_reg == 0x12)) && valxor) - pc87306_gpio_remove(dev); dev->regs[dev->cur_reg] = val; } else return; @@ -266,7 +263,7 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) } switch (dev->cur_reg) { - case 0: + case 0x00: if (valxor & 1) { lpt1_remove(); if ((val & 1) && !(dev->regs[2] & 1)) @@ -288,7 +285,7 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) fdc_set_base(dev->fdc, (val & 0x20) ? FDC_SECONDARY_ADDR : FDC_PRIMARY_ADDR); } break; - case 1: + case 0x01: if (valxor & 3) { lpt1_remove(); if ((dev->regs[0] & 1) && !(dev->regs[2] & 1)) @@ -305,7 +302,7 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) serial_handler(dev, 1); } break; - case 2: + case 0x02: if (valxor & 1) { lpt1_remove(); serial_remove(dev->uart[0]); @@ -329,23 +326,23 @@ pc87306_write(uint16_t port, uint8_t val, void *priv) lpt1_handler(dev); } break; - case 4: + case 0x04: if (valxor & 0x80) nvr_lock_set(0x00, 256, !!(val & 0x80), dev->nvr); break; - case 5: + case 0x05: if (valxor & 0x08) nvr_at_handler(!!(val & 0x08), 0x0070, dev->nvr); if (valxor & 0x20) nvr_bank_set(0, !!(val & 0x20), dev->nvr); break; - case 9: + case 0x09: if (valxor & 0x44) { fdc_update_enh_mode(dev->fdc, (val & 4) ? 1 : 0); fdc_update_densel_polarity(dev->fdc, (val & 0x40) ? 1 : 0); } break; - case 0xF: + case 0x0f: if (valxor) pc87306_gpio_handler(dev); break; diff --git a/src/sound/snd_sb.c b/src/sound/snd_sb.c index 0f94cbaff..478f82546 100644 --- a/src/sound/snd_sb.c +++ b/src/sound/snd_sb.c @@ -2024,6 +2024,7 @@ sb_16_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, &sb->dsp); + sb->gameport = gameport_add(&gameport_pnp_device); sb->gameport_addr = 0x200; return sb; @@ -2130,6 +2131,7 @@ sb_16_compat_init(const device_t *info) mpu401_init(sb->mpu, 0, 0, M_UART, info->local); sb_dsp_set_mpu(&sb->dsp, sb->mpu); + sb->gameport = gameport_add(&gameport_pnp_device); sb->gameport_addr = 0x200; return sb; @@ -2228,6 +2230,7 @@ sb_awe32_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, &sb->dsp); + sb->gameport = gameport_add(&gameport_pnp_device); sb->gameport_addr = 0x200; return sb; diff --git a/src/sound/sound.c b/src/sound/sound.c index a93cd27d1..f02e83bc5 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -219,7 +219,7 @@ sound_card_get_from_internal_name(const char *s) void sound_card_init(void) { - if (sound_cards[sound_card_current[0]].device) + if ((sound_card_current[0] != SOUND_INTERNAL) && (sound_cards[sound_card_current[0]].device)) device_add(sound_cards[sound_card_current[0]].device); if (sound_cards[sound_card_current[1]].device) device_add(sound_cards[sound_card_current[1]].device); @@ -512,14 +512,14 @@ sound_reset(void) filter_cd_audio_p = NULL; sound_set_cd_volume(65535, 65535); + + /* Reset the MPU-401 already loaded flag and the chain of input/output handlers. */ + midi_in_handlers_clear(); } void sound_card_reset(void) { - /* Reset the MPU-401 already loaded flag and the chain of input/output handlers. */ - midi_in_handlers_clear(); - sound_card_init(); if (mpu401_standalone_enable)