From 698a84999063bedf6a11503a81dc52096a776934 Mon Sep 17 00:00:00 2001 From: zakk4223 Date: Sat, 9 Sep 2023 05:53:46 -0400 Subject: [PATCH] Don't close existing filehandle if it is the same as the 'new' one. (fixes ao486 reset issue) (#814) --- ide.cpp | 2 +- ide_cdrom.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ide.cpp b/ide.cpp index 3e5abd1..4b342a1 100644 --- a/ide.cpp +++ b/ide.cpp @@ -418,7 +418,7 @@ void ide_img_set(uint32_t drvnum, fileTYPE *f, int cd, int sectors, int heads, i ide_inst[port].base = port ? IDE1_BASE : IDE0_BASE; ide_inst[port].drive[drv].drvnum = drvnum; - if (drive->f && drive->f->opened()) + if (drive->f && (f != drive->f) && drive->f->opened()) { FileClose(drive->f); } diff --git a/ide_cdrom.cpp b/ide_cdrom.cpp index 2cc7f21..33698b0 100644 --- a/ide_cdrom.cpp +++ b/ide_cdrom.cpp @@ -1491,7 +1491,6 @@ void cdrom_reply(ide_config *ide, uint8_t error, uint8_t asc_code, uint8_t ascq_ if (ide->drive[ide->regs.drv].mcr_flag && unit_attention) { ide->regs.status = ATA_STATUS_RDY | ATA_STATUS_IRQ | ATA_STATUS_ERR; ide->regs.error = (CD_ERR_UNIT_ATTENTION << 4) | ATA_ERR_MC; - ide->regs.sector_count = 0; ide->drive[ide->regs.drv].mcr_flag = false; } else