Skip to content

Commit 84f1bc2

Browse files
committed
wd33c9x: Add support for the Translate Address command
1 parent 32736e4 commit 84f1bc2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/devices/machine/wd33c9x.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,38 @@ void wd33c9x_base_device::start_command()
807807
step(false);
808808
break;
809809

810+
case COMMAND_CC_TRANSLATE_ADDRESS:
811+
LOGMASKED(LOG_COMMANDS, "Translate Address Command\n");
812+
{
813+
uint8_t total_sectors = m_regs[CDB_1];
814+
uint8_t total_heads = m_regs[CDB_2];
815+
uint16_t total_cylinders = m_regs[CDB_3] << 8 | m_regs[CDB_4];
816+
uint32_t lba = (m_regs[CDB_5] << 24) | (m_regs[CDB_6] << 16) | (m_regs[CDB_7] << 8) | (m_regs[CDB_8] << 0);
817+
818+
LOGMASKED(LOG_COMMANDS, "total_sectors=%02x, total_heads=%02x, total_cylinders=%04x, lba=%08x\n", total_sectors, total_heads, total_cylinders, lba);
819+
820+
uint16_t cylinder = lba / (total_sectors * total_heads);
821+
uint8_t head = (lba - (cylinder * total_sectors * total_heads)) / total_sectors;
822+
uint8_t sector = (lba - (cylinder * total_sectors * total_heads)) % total_sectors;
823+
824+
LOGMASKED(LOG_COMMANDS, "-> cylinder=%04x, head=%02x, sector=%02x\n", cylinder, head, sector);
825+
826+
m_regs[CDB_9] = sector;
827+
m_regs[CDB_10] = head;
828+
m_regs[CDB_11] = cylinder >> 8;
829+
m_regs[CDB_12] = cylinder >> 0;
830+
831+
m_regs[AUXILIARY_STATUS] &= ~(AUXILIARY_STATUS_CIP | AUXILIARY_STATUS_BSY);
832+
833+
if (cylinder >= total_cylinders)
834+
irq_fifo_push(SCSI_STATUS_LOGICAL_ADDRESS_TOO_LARGE);
835+
else
836+
irq_fifo_push(SCSI_STATUS_TRANSLATE_SUCCESS);
837+
838+
update_irq();
839+
}
840+
break;
841+
810842
case COMMAND_CC_TRANSFER_INFO:
811843
LOGMASKED(LOG_COMMANDS, "Transfer Info Command\n");
812844
if (m_mode != MODE_I) {

0 commit comments

Comments
 (0)