Support 115200 on Apple III [smf]

This commit is contained in:
smf- 2014-04-07 09:09:28 +00:00
parent c2bd08ec26
commit a62c91a086
3 changed files with 34 additions and 17 deletions

View File

@ -29,6 +29,7 @@ mos6551_device::mos6551_device(const machine_config &mconfig, const char *tag, d
m_rts(0), m_rts(0),
m_dtr(0), m_dtr(0),
m_xtal(0), m_xtal(0),
m_divide(0),
m_cts(1), m_cts(1),
m_dsr(1), m_dsr(1),
m_dcd(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[] = 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] = 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_dtr));
save_item(NAME(m_xtal)); save_item(NAME(m_xtal));
save_item(NAME(m_divide));
save_item(NAME(m_cts)); save_item(NAME(m_cts));
save_item(NAME(m_dsr)); save_item(NAME(m_dsr));
save_item(NAME(m_dcd)); 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() UINT8 mos6551_device::read_rdr()
{ {
m_status &= ~(SR_PARITY_ERROR | SR_FRAMING_ERROR | SR_OVERRUN | SR_RDRF); 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; m_control = data;
// bits 0-3 update_divider();
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);
// bit 4 // bit 4
m_rx_internal_clock = (m_control >> 4) & 1; m_rx_internal_clock = (m_control >> 4) & 1;
@ -407,6 +423,7 @@ void mos6551_device::set_xtal(UINT32 xtal)
if (started()) if (started())
{ {
m_internal_clock->set_unscaled_clock(m_xtal); m_internal_clock->set_unscaled_clock(m_xtal);
update_divider();
} }
} }

View File

@ -83,8 +83,6 @@ protected:
virtual machine_config_constructor device_mconfig_additions() const; virtual machine_config_constructor device_mconfig_additions() const;
private: private:
static const int m_divide = 16;
enum enum
{ {
SR_PARITY_ERROR = 0x01, SR_PARITY_ERROR = 0x01,
@ -136,6 +134,7 @@ private:
void output_dtr(int dtr); void output_dtr(int dtr);
void update_irq(); void update_irq();
void update_divider();
UINT8 read_rdr(); UINT8 read_rdr();
UINT8 read_status(); UINT8 read_status();
@ -177,6 +176,7 @@ private:
int m_dtr; int m_dtr;
UINT32 m_xtal; UINT32 m_xtal;
int m_divide;
int m_cts; int m_cts;
int m_dsr; int m_dsr;
int m_dcd; int m_dcd;

View File

@ -109,7 +109,7 @@ static MACHINE_CONFIG_START( apple3, apple3_state )
/* acia */ /* acia */
MCFG_DEVICE_ADD("acia", MOS6551, 0) MCFG_DEVICE_ADD("acia", MOS6551, 0)
MCFG_MOS6551_XTAL(XTAL_1_8432MHz) MCFG_MOS6551_XTAL(XTAL_1_8432MHz) // HACK: The schematic shows an external clock generator but using a XTAL is faster to emulate.
MCFG_MOS6551_IRQ_HANDLER(WRITELINE(apple3_state, apple3_acia_irq_func)) MCFG_MOS6551_IRQ_HANDLER(WRITELINE(apple3_state, apple3_acia_irq_func))
MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_txd)) MCFG_MOS6551_TXD_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_txd))
MCFG_MOS6551_RTS_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_rts)) MCFG_MOS6551_RTS_HANDLER(DEVWRITELINE("rs232", rs232_port_device, write_rts))