diff --git a/src/device/isapnp.c b/src/device/isapnp.c index 18b11ba3d..45752a3ca 100644 --- a/src/device/isapnp.c +++ b/src/device/isapnp.c @@ -414,7 +414,7 @@ isapnp_write_addr(uint16_t addr, uint8_t val, void *priv) if (!dev->key_pos) { isapnp_log("ISAPnP: Key unlocked, putting cards to SLEEP\n"); while (card) { - if (card->enable && (card->state == PNP_STATE_WAIT_FOR_KEY)) + if (card->enable && (card->enable != ISAPNP_CARD_NO_KEY) && (card->state == PNP_STATE_WAIT_FOR_KEY)) card->state = PNP_STATE_SLEEP; card = card->next; } @@ -974,14 +974,12 @@ isapnp_enable_card(void *priv, uint8_t enable) /* Look for a matching card. */ isapnp_card_t *card = dev->first_card; - uint8_t will_enable; while (card) { if (card == priv) { /* Enable or disable the card. */ - will_enable = (enable >= ISAPNP_CARD_ENABLE); - if (will_enable ^ card->enable) + if (!!enable ^ !!card->enable) card->state = (enable == ISAPNP_CARD_FORCE_CONFIG) ? PNP_STATE_CONFIG : PNP_STATE_WAIT_FOR_KEY; - card->enable = will_enable; + card->enable = enable; /* Invalidate other references if we're disabling this card. */ if (!card->enable) { diff --git a/src/include/86box/isapnp.h b/src/include/86box/isapnp.h index 38fc59d07..87272d86a 100644 --- a/src/include/86box/isapnp.h +++ b/src/include/86box/isapnp.h @@ -28,7 +28,8 @@ enum { ISAPNP_CARD_DISABLE = 0, ISAPNP_CARD_ENABLE = 1, - ISAPNP_CARD_FORCE_CONFIG /* cheat code for UMC UM8669F */ + ISAPNP_CARD_FORCE_CONFIG, /* cheat code for UMC UM8669F */ + ISAPNP_CARD_NO_KEY /* cheat code for Crystal CS423x */ }; diff --git a/src/sound/snd_cs423x.c b/src/sound/snd_cs423x.c index c1e19a630..fa0a5c13a 100644 --- a/src/sound/snd_cs423x.c +++ b/src/sound/snd_cs423x.c @@ -547,11 +547,8 @@ cs423x_pnp_enable(cs423x_t *dev, uint8_t update_rom, uint8_t update_hwconfig) if (update_rom) isapnp_update_card_rom(dev->pnp_card, &dev->ram_data[dev->pnp_offset], 384); - /* Hide PnP card if the PKD bit is set, or if PnP was disabled by command 0x55. */ - if ((dev->ram_data[0x4002] & 0x20) || !dev->pnp_enable) - isapnp_enable_card(dev->pnp_card, ISAPNP_CARD_DISABLE); - else - isapnp_enable_card(dev->pnp_card, ISAPNP_CARD_ENABLE); + /* Disable PnP key if the PKD bit is set, or if it was disabled by command 0x55. */ + isapnp_enable_card(dev->pnp_card, ((dev->ram_data[0x4002] & 0x20) || !dev->pnp_enable) ? ISAPNP_CARD_NO_KEY : ISAPNP_CARD_ENABLE); } /* Update some register bits based on the config data in RAM if requested. */