summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author dxl <41547105+hp9k@users.noreply.github.com>2018-10-07 14:51:49 +0200
committer R. Belmont <rb6502@users.noreply.github.com>2018-10-07 08:51:49 -0400
commite2665802eca35c829e9017a027e50a6e73aae138 (patch)
tree2886424be1c6e571aef035000dad8a675441f891
parentb26b436bfbda703a344586b1baa747f7ae07f9b2 (diff)
6840: fix dual byte mode once again (nw) (#4081)
* 6840: fix dual byte mode once again (nw) Two problems in dual byte mode: - the high time flag is the same for all counters - high time flag is reset on each counter reload, but should only be reset if the timer is reload by the user. * 6840: fix dual byte mode once again (nw)
-rw-r--r--src/devices/machine/6840ptm.cpp25
-rw-r--r--src/devices/machine/6840ptm.h2
2 files changed, 18 insertions, 9 deletions
diff --git a/src/devices/machine/6840ptm.cpp b/src/devices/machine/6840ptm.cpp
index b98cad197af..bf1e6f4adb1 100644
--- a/src/devices/machine/6840ptm.cpp
+++ b/src/devices/machine/6840ptm.cpp
@@ -136,7 +136,10 @@ void ptm6840_device::device_reset()
m_status_read_since_int = 0;
m_irq = 0;
m_t3_scaler = 0;
- m_hightime = false;
+ m_hightime[0] = false;
+ m_hightime[1] = false;
+ m_hightime[2] = false;
+
for (int i = 0; i < 3; i++)
{
m_counter[i] = 0xffff;
@@ -185,7 +188,7 @@ void ptm6840_device::subtract_from_counter(int counter, int count)
msb--;
// If MSB goes less than zero, we've expired
- if ((msb == 0 && !m_hightime) || (msb < 0 && m_hightime))
+ if ((msb == 0 && !m_hightime[counter]) || (msb < 0 && m_hightime[counter]))
{
timeout(counter);
msb = (m_latch[counter] >> 8) + 1;
@@ -224,7 +227,7 @@ void ptm6840_device::subtract_from_counter(int counter, int count)
if (m_control_reg[counter] & COUNT_MODE_8BIT)
{
/* In dual 8 bit mode, let the counter fire when MSB == 0 */
- m_hightime = !(clks & 0xff00);
+ m_hightime[counter] = !(clks & 0xff00);
clks &= 0xff00;
}
@@ -349,7 +352,7 @@ void ptm6840_device::reload_count(int idx)
// Copy the latched value in
m_counter[idx] = m_latch[idx];
- m_hightime = false;
+
// If reset is held, don't start counting
if (m_control_reg[0] & RESET_TIMERS)
return;
@@ -370,10 +373,11 @@ void ptm6840_device::reload_count(int idx)
int count = m_counter[idx];
if (m_control_reg[idx] & COUNT_MODE_8BIT)
{
- if (m_hightime)
+ if (m_hightime[idx])
count = 0xff;
else
count = ((count >> 8) + 1) * ((count & 0xff) + 1);
+
}
else
{
@@ -521,7 +525,7 @@ WRITE8_MEMBER( ptm6840_device::write )
{
m_timer[i]->enable(false);
m_enabled[i] = 0;
- m_hightime = false;
+ m_hightime[idx] = false;
}
}
// Releasing reset
@@ -529,6 +533,7 @@ WRITE8_MEMBER( ptm6840_device::write )
{
for (int i = 0; i < 3; i++)
{
+ m_hightime[idx] = false;
reload_count(i);
}
}
@@ -540,6 +545,7 @@ WRITE8_MEMBER( ptm6840_device::write )
// Changing the clock source? (e.g. Zwackery)
if (diffs & INTERNAL_CLK_EN)
{
+ m_hightime[idx] = false;
reload_count(idx);
}
break;
@@ -568,6 +574,7 @@ WRITE8_MEMBER( ptm6840_device::write )
// Reload the count if in an appropriate mode
if (!(m_control_reg[idx] & 0x10) || (m_control_reg[0] & RESET_TIMERS))
{
+ m_hightime[idx] = false;
reload_count(idx);
}
@@ -597,10 +604,11 @@ void ptm6840_device::timeout(int idx)
{
case 0:
case 2:
+
if (m_control_reg[idx] & COUNT_MODE_8BIT)
{
- m_hightime = !m_hightime;
- m_output[idx] = m_hightime;
+ m_hightime[idx] = !m_hightime[idx];
+ m_output[idx] = m_hightime[idx];
m_out_cb[idx](m_output[idx]);
}
else
@@ -645,6 +653,7 @@ void ptm6840_device::set_gate(int idx, int state)
{
if (state == 0 && m_gate[idx])
{
+ m_hightime[idx] = false;
reload_count(idx);
}
}
diff --git a/src/devices/machine/6840ptm.h b/src/devices/machine/6840ptm.h
index 5cb6b2a9711..ad5859b771b 100644
--- a/src/devices/machine/6840ptm.h
+++ b/src/devices/machine/6840ptm.h
@@ -129,7 +129,7 @@ private:
static const char *const opmode[];
// set in dual 8 bit mode to indicate Output high time cycle
- bool m_hightime;
+ bool m_hightime[3];
};