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)
{
case 0U:
if (BIT(m_input_x->read(), 1))
{
ioport_value const x(m_input_x->read());
// latch output data - remember MSB can be forced low by jumper
if (BIT(x, 1))
{
LOG("Latch data %02X\n", data);
m_data_latch = data;
m_printer_out->write(data & (BIT(x, 2) ? 0xffU : 0x7fU));
}
else
{
LOG("Output disabled, not latching data\n");
}
// start strobe if autostrobe is enabled
// latch output data and start strobe if autostrobe is enabled
LOG("Latch data %02X\n", data);
machine().scheduler().synchronize(
timer_expired_delegate(FUNC(a2bus_pic_device::data_write), this),
unsigned(data) | (1 << 8) | ((m_autostrobe_disable ? 0 : 1) << 9));
}
else
{
// just start strobe if autostrobe is enabled
LOG("Output disabled, not latching data\n");
if (!m_autostrobe_disable)
start_strobe();
machine().scheduler().synchronize(timer_expired_delegate(FUNC(a2bus_pic_device::data_write), this), 1 << 9);
}
break;
case 2U:
start_strobe();
machine().scheduler().synchronize(timer_expired_delegate(FUNC(a2bus_pic_device::data_write), this), 1 << 9);
break;
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
@ -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()
{
if (m_strobe_timer->enabled())

View File

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