summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/machine/mos6551.c
diff options
context:
space:
mode:
author smf- <smf-@users.noreply.github.com>2014-04-07 09:09:28 +0000
committer smf- <smf-@users.noreply.github.com>2014-04-07 09:09:28 +0000
commita62c91a0869cdc9e80b3151f5e23f862222c2dfe (patch)
treecc44c55b0dd154370b66c607e0772f6339081540 /src/emu/machine/mos6551.c
parentc2bd08ec266b7f20c057881b80252ea8a6aa1c90 (diff)
Support 115200 on Apple III [smf]
Diffstat (limited to 'src/emu/machine/mos6551.c')
-rw-r--r--src/emu/machine/mos6551.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/src/emu/machine/mos6551.c b/src/emu/machine/mos6551.c
index 9c777bcf6e8..97d118b86ae 100644
--- a/src/emu/machine/mos6551.c
+++ b/src/emu/machine/mos6551.c
@@ -29,6 +29,7 @@ mos6551_device::mos6551_device(const machine_config &mconfig, const char *tag, d
m_rts(0),
m_dtr(0),
m_xtal(0),
+ m_divide(0),
m_cts(1),
m_dsr(1),
m_dcd(1),
@@ -39,7 +40,7 @@ mos6551_device::mos6551_device(const machine_config &mconfig, const char *tag, d
const int mos6551_device::internal_divider[] =
{
- 0, 2304, 1536, 1048, 856, 768, 384, 192, 96, 64, 48, 32, 24, 16, 12, 6
+ 1, 2304, 1536, 1048, 856, 768, 384, 192, 96, 64, 48, 32, 24, 16, 12, 6
};
const int mos6551_device::transmitter_controls[4][3] =
@@ -86,6 +87,7 @@ void mos6551_device::device_start()
save_item(NAME(m_dtr));
save_item(NAME(m_xtal));
+ save_item(NAME(m_divide));
save_item(NAME(m_cts));
save_item(NAME(m_dsr));
save_item(NAME(m_dcd));
@@ -225,6 +227,32 @@ void mos6551_device::update_irq()
}
}
+void mos6551_device::update_divider()
+{
+ // bits 0-3
+ double scale = internal_divider[(m_control >> 0) & 0xf];
+
+ // The 6551 allows an external clock (hooked up to xtal1 with xtal2 floating) with the internal clock generator,
+ // it is unknown whether it allows a xtal (hooked up to xtal1 & xtal2) to be used as an external clock. It is
+ // allowed here for performance reasons.
+ if (m_xtal != 0)
+ {
+ m_tx_internal_clock = true;
+
+ m_divide = 16;
+ scale = (double) 1 / scale;
+ }
+ else
+ {
+ m_tx_internal_clock = false;
+
+ m_divide = scale * 16;
+ scale = 0;
+ }
+
+ m_internal_clock->set_clock_scale(scale);
+}
+
UINT8 mos6551_device::read_rdr()
{
m_status &= ~(SR_PARITY_ERROR | SR_FRAMING_ERROR | SR_OVERRUN | SR_RDRF);
@@ -277,19 +305,7 @@ void mos6551_device::write_control(UINT8 data)
{
m_control = data;
- // bits 0-3
- double scale = internal_divider[(m_control >> 0) & 0xf];
- if (scale != 0)
- {
- m_tx_internal_clock = true;
- scale = (double) 1 / scale;
- }
- else
- {
- m_tx_internal_clock = false;
- }
-
- m_internal_clock->set_clock_scale(scale);
+ update_divider();
// bit 4
m_rx_internal_clock = (m_control >> 4) & 1;
@@ -407,6 +423,7 @@ void mos6551_device::set_xtal(UINT32 xtal)
if (started())
{
m_internal_clock->set_unscaled_clock(m_xtal);
+ update_divider();
}
}