Skip to content

Commit 7b839b6

Browse files
authored
sinclair/specnext_dma.cpp: Fixed counter state returning natural value in ZXN mode. (#15179)
1 parent eea4b47 commit 7b839b6

4 files changed

Lines changed: 17 additions & 16 deletions

File tree

src/devices/machine/z80dma.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ TIMER_CALLBACK_MEMBER(z80dma_device::clock_w)
601601
m_addressA = PORTA_ADDRESS;
602602
m_addressB = PORTB_ADDRESS;
603603
m_count = BLOCKLEN;
604-
m_byte_counter = 0;
604+
reset_byte_counter();
605605
m_status |= 0x30;
606606
enable();
607607
}
@@ -792,7 +792,7 @@ void z80dma_device::write(u8 data)
792792
m_addressA = PORTA_ADDRESS;
793793
m_addressB = PORTB_ADDRESS;
794794
m_count = BLOCKLEN;
795-
m_byte_counter = 0;
795+
reset_byte_counter();
796796
m_status |= 0x30;
797797

798798
LOGREGS("CMD Load A: %x B: %x N: %x\n", m_addressA, m_addressB, m_count);
@@ -812,7 +812,7 @@ void z80dma_device::write(u8 data)
812812
case COMMAND_CONTINUE:
813813
LOGREGS("CMD Continue\n");
814814
m_count = BLOCKLEN;
815-
m_byte_counter = 0;
815+
reset_byte_counter();
816816
//enable(); //???m_dma_enabled = 1;
817817
//"match not found" & "end of block" status flags zeroed here
818818
m_status |= 0x30;

src/devices/machine/z80dma.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,15 @@ class z80dma_device : public device_t,
118118
void enable();
119119
void disable();
120120
u8 num_follow() const noexcept { return m_num_follow; }
121-
virtual int is_ready();
121+
int is_ready();
122122
void interrupt_check();
123123
void trigger_interrupt(int level);
124-
virtual void do_read();
124+
void do_read();
125125
void do_write();
126126
void do_transfer_write();
127127
void do_search();
128128
void setup_next_read(int rr);
129+
virtual void reset_byte_counter() { m_byte_counter = 0; };
129130

130131
virtual TIMER_CALLBACK_MEMBER(clock_w);
131132

src/mame/sinclair/specnext_dma.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ specnext_dma_device::specnext_dma_device(const machine_config &mconfig, const ch
4242
{
4343
}
4444

45+
void specnext_dma_device::reset_byte_counter()
46+
{
47+
m_byte_counter = m_dma_mode ? 0 : 1;
48+
}
49+
4550
void specnext_dma_device::write(u8 data)
4651
{
4752
if (num_follow() == 0)
@@ -52,7 +57,7 @@ void specnext_dma_device::write(u8 data)
5257
switch (data)
5358
{
5459
case COMMAND_ENABLE_DMA:
55-
m_byte_counter = 0;
60+
reset_byte_counter();
5661
break;
5762
case COMMAND_RESET:
5863
m_r2_portB_preescaler_s = 0;
@@ -78,14 +83,6 @@ void specnext_dma_device::write(u8 data)
7883
}
7984
}
8085

81-
void specnext_dma_device::do_read()
82-
{
83-
z80dma_device::do_read();
84-
// zxnDMA?
85-
if (m_dma_mode == 0 && (m_byte_counter + 1) == m_count)
86-
m_byte_counter++;
87-
}
88-
8986
TIMER_CALLBACK_MEMBER(specnext_dma_device::clock_w)
9087
{
9188
if (m_dma_delay)
@@ -111,7 +108,10 @@ TIMER_CALLBACK_MEMBER(specnext_dma_device::clock_w)
111108
}
112109

113110
const bool may_prescaled = m_dma_seq == SEQ_TRANS1_WRITE_DEST && m_r2_portB_preescaler_s;
114-
z80dma_device::clock_w(param);
111+
if (m_dma_mode == 0 && m_dma_seq == SEQ_WAIT_READY && is_ready() && m_byte_counter == 1)
112+
m_dma_seq = SEQ_REQUEST_BUS;
113+
else
114+
z80dma_device::clock_w(param);
115115

116116
if (may_prescaled && m_dma_seq != SEQ_FINISH)
117117
{

src/mame/sinclair/specnext_dma.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class specnext_dma_device : public z80dma_device
2121
virtual void device_start() override ATTR_COLD;
2222
virtual void device_reset() override ATTR_COLD;
2323

24-
virtual void do_read() override;
24+
virtual void reset_byte_counter() override;
2525

2626
virtual TIMER_CALLBACK_MEMBER(clock_w) override;
2727

0 commit comments

Comments
 (0)