Skip to content

Commit 230b7bd

Browse files
kbloodclaude
andauthored
ide: strip DSC (SERVICE) bit for ATAPI to fix Win9x CD Code 10 (MiSTer-devel#1221)
ide_set_regs() synthesizes status bit 4 as DSC for every device. For an ATAPI (packet) device bit 4 is the SERVICE bit, not DSC, and since we never run overlapped/queued commands it must read 0. 86Box masks DSC out of every ATAPI status read and reports SERVICE=0 for a non-overlapped device. The permanent SERVICE=1 made Win9x's ESDI_506 reject the channel (Device Manager Code 10, "ESDI access to drive failed (IRQ?), so punting"), even though the completion IRQ was delivered. Strip DSC for CD drives to match the reference. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6af572c commit 230b7bd

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

ide.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ void ide_set_regs(ide_config *ide)
162162
{
163163
if (!(ide->regs.status & (ATA_STATUS_BSY | ATA_STATUS_ERR))) ide->regs.status |= ATA_STATUS_DSC;
164164

165+
// For ATAPI (packet) devices, status bit 4 is the SERVICE bit, not DSC. We never run
166+
// overlapped commands, so SERVICE must read 0. Force it low for CD drives, matching 86Box
167+
// ide_status() which masks DSC out of every ATAPI status read (hdc_ide.c). Win9x ESDI_506
168+
// otherwise reads the permanent bit-4 as "overlapped-command SERVICE pending", rejects the
169+
// channel, and the device fails to start (Device Manager Code 10).
170+
if (ide->drive[ide->regs.drv].cd) ide->regs.status &= ~ATA_STATUS_DSC;
171+
165172
uint8_t data[12] =
166173
{
167174
(uint8_t)((ide->drive[ide->regs.drv].cd) ? 0x80 : ide->regs.io_size),

0 commit comments

Comments
 (0)