Fixed IDE sector advancement, fixes #4012.

This commit is contained in:
OBattler
2024-01-09 23:49:09 +01:00
parent 25b04d84ba
commit ce342400eb

View File

@@ -734,19 +734,25 @@ ide_get_sector(ide_t *ide)
static void
ide_next_sector(ide_t *ide)
{
uint32_t sector = ide->tf->sector;
uint32_t head = ide->tf->head;
if (ide->tf->lba)
ide->lba_addr++;
else {
ide->tf->sector++;
if ((ide->tf->sector == 0) || (ide->tf->sector == (ide->cfg_spt + 1))) {
ide->tf->sector = 1;
ide->tf->head++;
if ((ide->tf->head == 0) || (ide->head == ide->cfg_hpc)) {
ide->tf->head = 0;
sector++;
if ((sector == 0) || (sector == (ide->cfg_spt + 1))) {
sector = 1;
head++;
if (head == ide->cfg_hpc) {
head = 0;
ide->tf->cylinder++;
}
}
}
ide->tf->sector = sector & 0xff;
ide->tf->head = head & 0x0f;
}
static void
@@ -1411,8 +1417,7 @@ ide_write_devctl(UNUSED(uint16_t addr), uint8_t val, void *priv)
old = dev->devctl;
dev->devctl = val;
// if (!(val & 0x02) && (old & 0x02))
if ((old ^ val) & 0x02)
if (!(val & 0x02) && (old & 0x02))
ide_irq_update(ide_boards[ide->board], 1);
}