bus/a2bus: Also synchronise data and asserting strobe for Apple II Parallel Interface Card.

This commit is contained in:
Vas Crabb 2021-04-04 03:25:53 +10:00
parent c6c0f2f3ec
commit 49006281c1
2 changed files with 44 additions and 37 deletions

View File

@ -177,29 +177,25 @@ void a2bus_pic_device::write_c0nx(u8 offset, u8 data)
switch (offset & 0x07U) switch (offset & 0x07U)
{ {
case 0U: case 0U:
if (BIT(m_input_x->read(), 1))
{ {
ioport_value const x(m_input_x->read()); // latch output data and start strobe if autostrobe is enabled
// latch output data - remember MSB can be forced low by jumper
if (BIT(x, 1))
{
LOG("Latch data %02X\n", data); LOG("Latch data %02X\n", data);
m_data_latch = data; machine().scheduler().synchronize(
m_printer_out->write(data & (BIT(x, 2) ? 0xffU : 0x7fU)); timer_expired_delegate(FUNC(a2bus_pic_device::data_write), this),
unsigned(data) | (1 << 8) | ((m_autostrobe_disable ? 0 : 1) << 9));
} }
else else
{ {
// just start strobe if autostrobe is enabled
LOG("Output disabled, not latching data\n"); LOG("Output disabled, not latching data\n");
}
// start strobe if autostrobe is enabled
if (!m_autostrobe_disable) if (!m_autostrobe_disable)
start_strobe(); machine().scheduler().synchronize(timer_expired_delegate(FUNC(a2bus_pic_device::data_write), this), 1 << 9);
} }
break; break;
case 2U: case 2U:
start_strobe(); machine().scheduler().synchronize(timer_expired_delegate(FUNC(a2bus_pic_device::data_write), this), 1 << 9);
break; break;
case 5U: case 5U:
@ -408,6 +404,36 @@ void a2bus_pic_device::set_fault_in(void *ptr, s32 param)
} }
void a2bus_pic_device::data_write(void *ptr, s32 param)
{
// latch output data - remember MSB can be forced low by jumper
if (BIT(param, 8))
{
m_data_latch = u8(u32(param));
m_printer_out->write(m_data_latch & (BIT(m_input_x->read(), 2) ? 0xffU : 0x7fU));
}
// start/extend strobe output
if (BIT(param, 9))
{
ioport_value const sw1(m_input_sw1->read());
unsigned const cycles(15U - ((sw1 & 0x07U) << 1));
int const state(BIT(sw1, 3));
if (!m_strobe_timer->enabled())
{
LOG("Output /STROBE=%d for %u cycles\n", state, cycles);
clear_ack_latch();
m_printer_conn->write_strobe(state);
}
else
{
LOG("Adjust /STROBE=%d remaining to %u cycles\n", state, cycles);
}
m_strobe_timer->adjust(attotime::from_ticks(cycles * 7, clock()));
}
}
//---------------------------------------------- //----------------------------------------------
// helpers // helpers
@ -425,25 +451,6 @@ void a2bus_pic_device::reset_mode()
} }
void a2bus_pic_device::start_strobe()
{
ioport_value const sw1(m_input_sw1->read());
unsigned const cycles(15U - ((sw1 & 0x07U) << 1));
int const state(BIT(sw1, 3));
if (!m_strobe_timer->enabled())
{
LOG("Output /STROBE=%d for %u cycles\n", state, cycles);
clear_ack_latch();
m_printer_conn->write_strobe(state);
}
else
{
LOG("Adjust /STROBE=%d remaining to %u cycles\n", state, cycles);
}
m_strobe_timer->adjust(attotime::from_ticks(cycles, clock()));
}
void a2bus_pic_device::set_ack_latch() void a2bus_pic_device::set_ack_latch()
{ {
if (m_strobe_timer->enabled()) if (m_strobe_timer->enabled())

View File

@ -96,10 +96,10 @@ private:
void set_perror_in(void *ptr, s32 param); void set_perror_in(void *ptr, s32 param);
void set_select_in(void *ptr, s32 param); void set_select_in(void *ptr, s32 param);
void set_fault_in(void *ptr, s32 param); void set_fault_in(void *ptr, s32 param);
void data_write(void *ptr, s32 param);
// helpers // helpers
void reset_mode(); void reset_mode();
void start_strobe();
void set_ack_latch(); void set_ack_latch();
void clear_ack_latch(); void clear_ack_latch();
void enable_irq(); void enable_irq();