From fd93123881d00fc030d0b86053118497c334d698 Mon Sep 17 00:00:00 2001 From: AJR Date: Mon, 6 Jan 2025 23:07:44 -0500 Subject: machine/ncr53c90.cpp: Fix NCR53CF94 ID read sequence --- src/devices/machine/ncr53c90.cpp | 28 +++++++++++++++++++--------- src/devices/machine/ncr53c90.h | 3 +++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/devices/machine/ncr53c90.cpp b/src/devices/machine/ncr53c90.cpp index 73ebf10ab27..9612cfecb4f 100644 --- a/src/devices/machine/ncr53c90.cpp +++ b/src/devices/machine/ncr53c90.cpp @@ -918,6 +918,15 @@ void ncr53c90_device::command_pop_and_chain() } } +void ncr53c90_device::load_tcounter() +{ + LOGMASKED(LOG_COMMAND, "DMA command: tcounter reloaded to %d\n", tcount & tcounter_mask); + tcounter = tcount & tcounter_mask; + + // clear transfer count zero flag when counter is reloaded + status &= ~S_TC0; +} + void ncr53c90_device::start_command() { uint8_t c = command[0] & 0x7f; @@ -932,11 +941,7 @@ void ncr53c90_device::start_command() dma_command = command[0] & 0x80; if (dma_command) { - LOGMASKED(LOG_COMMAND, "DMA command: tcounter reloaded to %d\n", tcount); - tcounter = tcount; - - // clear transfer count zero flag when counter is reloaded - status &= ~S_TC0; + load_tcounter(); } else { @@ -1417,6 +1422,15 @@ void ncr53cf94_device::device_reset() ncr53c94_device::device_reset(); } +void ncr53cf94_device::load_tcounter() +{ + ncr53c94_device::load_tcounter(); + + // ID may be read by executing DMA NOP command twice, first with the features bit clear and then with it set + if ((config2 & S2FE) == 0) + tcount = (1 << 23) | (family_id << 19) | (revision_level << 16) | (tcount & 0xffff); +} + void ncr53cf94_device::conf2_w(uint8_t data) { tcounter_mask = (data & S2FE) ? 0xffffff : 0xffff; @@ -1425,10 +1439,6 @@ void ncr53cf94_device::conf2_w(uint8_t data) uint8_t ncr53cf94_device::tcounter_hi2_r() { - // tcounter is 24-bit when the features bit is set, otherwise it returns the ID - if ((config2 & S2FE) == 0) - return (1 << 7) | (family_id << 3) | revision_level; - LOG("tcounter_hi2_r %02x (%s)\n", (tcounter >> 16) & 0xff, machine().describe_context()); return tcounter >> 16; } diff --git a/src/devices/machine/ncr53c90.h b/src/devices/machine/ncr53c90.h index 1f17b14e7ad..7c7ad3d0896 100644 --- a/src/devices/machine/ncr53c90.h +++ b/src/devices/machine/ncr53c90.h @@ -232,6 +232,7 @@ protected: void delay_cycles(int cycles); void decrement_tcounter(int count = 1); + virtual void load_tcounter(); devcb_write_line m_irq_handler; devcb_write_line m_drq_handler; @@ -361,6 +362,8 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; + virtual void load_tcounter() override; + private: u8 config4; u8 family_id; -- cgit v1.2.3