summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Patrick Mackinlay <pmackinlay@hotmail.com>2023-01-31 16:03:31 +0700
committer Patrick Mackinlay <pmackinlay@hotmail.com>2023-01-31 16:03:31 +0700
commit12e5fa39063ba0fdba6dc81a08fbb07811f2a611 (patch)
tree9e2e558fcc5f9e73324ac7a2ad2b5ea13db88641
parentfaa0ede657c2d83f08f83738ec078457abae3931 (diff)
z80dma: improved end of block test
-rw-r--r--src/devices/machine/z80dma.cpp35
-rw-r--r--src/devices/machine/z80dma.h2
2 files changed, 11 insertions, 26 deletions
diff --git a/src/devices/machine/z80dma.cpp b/src/devices/machine/z80dma.cpp
index 3793855471d..72b77850891 100644
--- a/src/devices/machine/z80dma.cpp
+++ b/src/devices/machine/z80dma.cpp
@@ -454,16 +454,11 @@ void z80dma_device::do_search()
}
}
-int z80dma_device::do_write()
+void z80dma_device::do_write()
{
- int done;
uint8_t mode;
mode = TRANSFER_MODE;
- if (m_byte_counter == 0x0000)
- {
- //FIXME: Any signal here
- }
switch(mode) {
case TM_TRANSFER:
do_transfer_write();
@@ -487,19 +482,6 @@ int z80dma_device::do_write()
m_addressB += PORTB_FIXED ? 0 : PORTB_INC ? 1 : -1;
m_byte_counter++;
- /*
- * HACK: The user manual states that 216+1 bytes are transferred when the
- * block length is set to zero, however it also states the maximum length
- * is 64Kbytes. For transfers less than the maximum, the value in the block
- * length regster is set to N-1.
- */
- done = (m_byte_counter == (m_count ? m_count + 1 : m_count));
-
- if (done)
- {
- //FIXME: interrupt ?
- }
- return done;
}
@@ -509,8 +491,6 @@ int z80dma_device::do_write()
TIMER_CALLBACK_MEMBER(z80dma_device::timerproc)
{
- int done;
-
if (--m_cur_cycle)
{
return;
@@ -522,18 +502,20 @@ TIMER_CALLBACK_MEMBER(z80dma_device::timerproc)
{
/* TODO: there's a nasty recursion bug with Alpha for Sharp X1 Turbo on the transfers with this function! */
do_read();
- done = 0;
m_is_read = false;
m_cur_cycle = (PORTA_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN);
}
else
{
- done = do_write();
+ do_write();
m_is_read = true;
m_cur_cycle = (PORTB_IS_SOURCE ? PORTA_CYCLE_LEN : PORTB_CYCLE_LEN);
+
+ // param==1 indicates final transfer
+ m_timer->set_param(m_byte_counter == m_count);
}
- if (done)
+ if (m_is_read && param)
{
m_dma_enabled = 0; //FIXME: Correct?
m_status = 0x09;
@@ -560,6 +542,7 @@ TIMER_CALLBACK_MEMBER(z80dma_device::timerproc)
m_count = BLOCKLEN;
m_byte_counter = 0;
m_status |= 0x30;
+ m_timer->set_param(0);
}
}
}
@@ -581,7 +564,7 @@ void z80dma_device::update_status()
attotime const next = attotime::from_hz(clock());
m_timer->adjust(
attotime::zero,
- 0,
+ m_timer->param(),
// 1 byte transferred in 4 clock cycles
next);
}
@@ -752,6 +735,7 @@ void z80dma_device::write(uint8_t data)
m_count = BLOCKLEN;
m_byte_counter = 0;
m_status |= 0x30;
+ m_timer->set_param(0);
LOG("Z80DMA Load A: %x B: %x N: %x\n", m_addressA, m_addressB, m_count);
break;
@@ -774,6 +758,7 @@ void z80dma_device::write(uint8_t data)
m_dma_enabled = 1;
//"match not found" & "end of block" status flags zeroed here
m_status |= 0x30;
+ m_timer->set_param(0);
break;
case COMMAND_RESET_PORT_A_TIMING:
LOG("Z80DMA Reset Port A Timing\n");
diff --git a/src/devices/machine/z80dma.h b/src/devices/machine/z80dma.h
index 26613e74b80..5db9112fc30 100644
--- a/src/devices/machine/z80dma.h
+++ b/src/devices/machine/z80dma.h
@@ -83,7 +83,7 @@ private:
void interrupt_check();
void trigger_interrupt(int level);
void do_read();
- int do_write();
+ void do_write();
void do_transfer_write();
void do_search();