From 265feab6fd06a8aaa0f0296f1093d79920ab463e Mon Sep 17 00:00:00 2001 From: "R. Belmont" Date: Tue, 27 May 2014 02:45:11 +0000 Subject: [PATCH] ncr539x: fix FIFO read/writing to work as expected. (nw) --- src/emu/machine/ncr539x.c | 16 ++++++++++------ src/emu/machine/ncr539x.h | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/emu/machine/ncr539x.c b/src/emu/machine/ncr539x.c index 21a4a4e03f8..7b53fc345db 100644 --- a/src/emu/machine/ncr539x.c +++ b/src/emu/machine/ncr539x.c @@ -57,9 +57,9 @@ static const char *rdregs[16] = { "Command", // 3 "Status", // 4 "Interrupt Status", // 5 - "Internal State", - "Current FIFO/Internal State", - "Control Register 1", + "Internal State", // 6 + "Current FIFO/Internal State", // 7 + "Control Register 1", // 8 "0x9", "0xA", "Control Register 2", @@ -143,6 +143,7 @@ void ncr539x_device::device_start() void ncr539x_device::device_reset() { m_fifo_ptr = 0; + m_fifo_read_ptr = 0; m_irq_status = 0; m_status = SCSI_PHASE_STATUS; m_internal_state = 0; @@ -318,14 +319,15 @@ READ8_MEMBER( ncr539x_device::read ) } else { - rv = m_fifo[m_fifo_ptr++]; + rv = m_fifo[m_fifo_read_ptr++]; + m_fifo_read_ptr &= (m_fifo_size-1); fifo_bytes--; m_xfer_count--; update_fifo_internal_state(fifo_bytes); #if VERBOSE - printf("Read %02x from FIFO[%d], FIFO now contains %d bytes (PC=%x, m_buffer_remaining %x)\n", rv, m_fifo_ptr-1, fifo_bytes, space.device().safe_pc(), m_buffer_remaining); + printf("Read %02x from FIFO[%d], FIFO now contains %d bytes (PC=%x, m_buffer_remaining %x)\n", rv, m_fifo_read_ptr-1, fifo_bytes, space.device().safe_pc(), m_buffer_remaining); #endif if (fifo_bytes == 0) @@ -432,7 +434,8 @@ READ8_MEMBER( ncr539x_device::read ) WRITE8_MEMBER( ncr539x_device::write ) { #if VERBOSE - if (offset != 2) printf("539x: Write %02x @ %s (%02x) (PC=%x)\n", data, wrregs[offset], offset, space.device().safe_pc()); + //if (offset != 2) + printf("539x: Write %02x @ %s (%02x) (PC=%x)\n", data, wrregs[offset], offset, space.device().safe_pc()); #endif switch (offset) @@ -757,6 +760,7 @@ void ncr539x_device::fifo_write(UINT8 data) printf("539x: Write %02x @ FIFO[%x]\n", data, m_fifo_ptr); #endif m_fifo[m_fifo_ptr++] = data; + update_fifo_internal_state(m_fifo_ptr); if (m_selected) { diff --git a/src/emu/machine/ncr539x.h b/src/emu/machine/ncr539x.h index f5308ccd95b..ec8eb1112f3 100644 --- a/src/emu/machine/ncr539x.h +++ b/src/emu/machine/ncr539x.h @@ -65,7 +65,7 @@ private: bool m_chipid_available, m_chipid_lock; static const int m_fifo_size = 16; - UINT8 m_fifo_ptr, m_fifo[m_fifo_size]; + UINT8 m_fifo_ptr, m_fifo_read_ptr, m_fifo[m_fifo_size]; //int m_xfer_remaining; // amount in the FIFO when we're in data in phase