@@ -160,14 +160,11 @@ void ide_get_regs(ide_config *ide)
160160
161161void ide_set_regs (ide_config *ide)
162162{
163- if (!(ide->regs .status & (ATA_STATUS_BSY | ATA_STATUS_ERR ))) ide->regs .status |= ATA_STATUS_DSC ;
164-
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 ;
163+ // Auto-assert DSC for non-CD drives only; let each ATAPI command set its own status.
164+ if (!ide->drive [ide->regs .drv ].cd && !(ide->regs .status & (ATA_STATUS_BSY | ATA_STATUS_ERR )))
165+ {
166+ ide->regs .status |= ATA_STATUS_DSC ;
167+ }
171168
172169 uint8_t data[12 ] =
173170 {
@@ -1016,7 +1013,8 @@ void ide_io(int num, int req)
10161013 else if (ide->state == IDE_STATE_WAIT_PKT_RD )
10171014 {
10181015 if (ide->regs .pkt_cnt ) cdrom_read (ide);
1019- else cdrom_reply (ide, 0 );
1016+ // A successful data-phase completion must report GOOD, not UNIT ATTENTION.
1017+ else cdrom_reply (ide, 0 , 0 , 0 , false );
10201018 }
10211019 else if (ide->state == IDE_STATE_WAIT_PKT_MODE )
10221020 {
@@ -1049,7 +1047,8 @@ void ide_io(int num, int req)
10491047
10501048 ide_get_regs (ide);
10511049 ide->regs .head = 0 ;
1052- ide->regs .error = 0 ;
1050+ // ATAPI posts diagnostic code 01h after a bus reset; an ATA HDD posts 0.
1051+ ide->regs .error = ide->drive [ide->regs .drv ].cd ? 1 : 0 ;
10531052 ide->regs .sector = 1 ;
10541053 ide->regs .sector_count = 1 ;
10551054 ide->regs .cylinder = (!ide->drive [ide->regs .drv ].present ) ? 0xFFFF : ide->drive [ide->regs .drv ].cd ? 0xEB14 : 0x0000 ;
0 commit comments