macadb: support telling ADB devices to enable/disable SRQ. [R. Belmont]

Eliminates the need for the "iigs_mode" hack since the IIgs firmware knows the MCU program is buggy and disables mouse SRQs.
This commit is contained in:
arbee 2023-01-07 23:09:27 -05:00
parent 3f7eee6219
commit 1b5a85c044
3 changed files with 44 additions and 21 deletions

View File

@ -3775,7 +3775,6 @@ void apple2gs_state::apple2gs(machine_config &config)
MACADB(config, m_macadb, A2GS_MASTER_CLOCK/8);
m_macadb->set_mcu_mode(true);
m_macadb->set_iigs_mode(true);
m_macadb->adb_data_callback().set(FUNC(apple2gs_state::set_adb_line));
RTC3430042(config, m_rtc, XTAL(32'768));

View File

@ -240,7 +240,6 @@ macadb_device::macadb_device(const machine_config &mconfig, const char *tag, dev
write_adb_data(*this),
write_adb_irq(*this),
m_bIsMCUMode(true),
m_bIsIIGSMode(false),
m_last_kbd{0, 0},
m_last_mouse{0, 0}
{
@ -300,6 +299,8 @@ void macadb_device::device_start()
save_item(NAME(m_adb_linein));
save_item(NAME(m_last_kbd));
save_item(NAME(m_last_mouse));
save_item(NAME(m_mouse_handler));
save_item(NAME(m_keyboard_handler));
}
WRITE_LINE_MEMBER(macadb_device::adb_data_w)
@ -586,6 +587,7 @@ void macadb_device::adb_talk()
{
LOGMASKED(LOG_TALK_LISTEN, "ADB LISTEN to unknown device %d, timing out\n", addr);
m_adb_direction = 0;
machine().debug_break();
}
break;
@ -630,7 +632,7 @@ void macadb_device::adb_talk()
{
m_adb_datasize = 0;
if (adb_pollkbd(0)) //&& (!m_bIsIIGSMode))
if ((adb_pollkbd(0)) && (m_keyboard_handler & 0x20))
{
LOGMASKED(LOG_TALK_LISTEN, "Keyboard requesting service\n");
m_adb_srqflag = true;
@ -640,7 +642,7 @@ void macadb_device::adb_talk()
// get ID/handler
case 3:
m_adb_buffer[0] = 0x60 | (m_adb_mouseaddr&0xf); // SRQ enable, no exceptional event
m_adb_buffer[0] = m_mouse_handler;
m_adb_buffer[1] = 0x01; // handler 1
m_adb_datasize = 2;
@ -653,7 +655,6 @@ void macadb_device::adb_talk()
}
else if (addr == m_adb_keybaddr)
{
// int kbd_has_data = 1;
LOGMASKED(LOG_TALK_LISTEN, "Talking to keyboard, register %x\n", reg);
switch (reg)
@ -700,7 +701,7 @@ void macadb_device::adb_talk()
{
m_adb_datasize = 0;
if ((adb_pollmouse()) && (!m_bIsIIGSMode))
if ((adb_pollmouse()) && (m_mouse_handler & 0x20))
{
LOGMASKED(LOG_TALK_LISTEN, "Mouse requesting service\n");
m_adb_srqflag = true;
@ -720,7 +721,7 @@ void macadb_device::adb_talk()
// get ID/handler
case 3:
m_adb_buffer[0] = 0x60 | (m_adb_keybaddr&0xf); // SRQ enable, no exceptional event
m_adb_buffer[0] = m_keyboard_handler;
m_adb_buffer[1] = 0x01; // handler 1
m_adb_datasize = 2;
@ -746,24 +747,49 @@ void macadb_device::adb_talk()
else
{
LOGMASKED(LOG_TALK_LISTEN, "Got LISTEN data %02x %02x for device %x reg %x\n", m_adb_command, m_adb_buffer[1], m_adb_listenaddr, m_adb_listenreg);
m_adb_direction = 0;
if (m_adb_listenaddr == m_adb_mouseaddr)
{
if ((m_adb_listenreg == 3) && (m_adb_command > 0) && (m_adb_command < 16))
if (m_adb_listenreg == 3)
{
LOGMASKED(LOG_TALK_LISTEN, "MOUSE: moving to address %x\n", m_adb_command);
m_adb_mouseaddr = m_adb_command&0x0f;
m_adb_mouse_initialized = 1;
switch (m_adb_buffer[1])
{
case 0x00: // unconditional set handler & address to value
LOGMASKED(LOG_TALK_LISTEN, "MOUSE: moving to address & setting handler bits to %02x\n", m_adb_command);
m_mouse_handler = m_adb_command & 0x7f;
m_adb_mouseaddr = m_adb_command & 0x0f;
break;
case 0xfe: // unconditional address change
LOGMASKED(LOG_TALK_LISTEN, "MOUSE: moving to address %x\n", m_adb_command);
m_adb_mouseaddr = m_adb_command & 0x0f;
m_mouse_handler &= 0xf0;
m_mouse_handler |= m_adb_mouseaddr;
m_adb_mouse_initialized = 1;
break;
}
}
}
else if (m_adb_listenaddr == m_adb_keybaddr)
{
if ((m_adb_listenreg == 3) && (m_adb_command > 0) && (m_adb_command < 16))
if (m_adb_listenreg == 3)
{
LOGMASKED(LOG_TALK_LISTEN, "KEYBOARD: moving to address %x\n", m_adb_command);
m_adb_keybaddr = m_adb_command&0x0f;
switch (m_adb_buffer[1])
{
case 0x00: // unconditional set handler & address to value
LOGMASKED(LOG_TALK_LISTEN, "KEYBOARD: moving to address & setting handler bits to %02x\n", m_adb_command);
m_keyboard_handler = m_adb_command & 0x7f;
m_adb_keybaddr = m_adb_command & 0x0f;
break;
case 0xfe: // unconditional address change
LOGMASKED(LOG_TALK_LISTEN, "KEYBOARD: moving to address %x\n", m_adb_command);
m_adb_keybaddr = m_adb_command & 0x0f;
m_keyboard_handler &= 0xf0;
m_keyboard_handler |= m_adb_keybaddr;
break;
}
}
}
}
@ -1060,11 +1086,13 @@ void macadb_device::device_reset()
// mouse
m_adb_mouseaddr = 3;
m_mouse_handler = 0x23;
m_adb_lastmousex = m_adb_lastmousey = m_adb_lastbutton = 0;
m_adb_mouse_initialized = 0;
// keyboard
m_adb_keybaddr = 2;
m_keyboard_handler = 0x22;
m_adb_keybinitialized = 0;
m_adb_currentkeys[0] = m_adb_currentkeys[1] = 0xff;
m_adb_modifiers = 0xff;

View File

@ -20,10 +20,6 @@ public:
macadb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
void set_mcu_mode(bool bMCUMode) { m_bIsMCUMode = bMCUMode; }
// TODO: the IIgs microcontroller programs hate how we generate SRQs, and they already
// do round-robin polling so no data will be missed. This lets us turn off SRQs for that case.
// We should see if we can make them happier, or just work on LLE ADB devices...
void set_iigs_mode(bool bIIGSMode) { m_bIsIIGSMode = bIIGSMode; }
auto via_clock_callback() { return write_via_clock.bind(); }
auto via_data_callback() { return write_via_data.bind(); }
@ -48,7 +44,7 @@ protected:
virtual void device_reset() override;
private:
bool m_bIsMCUMode, m_bIsIIGSMode;
bool m_bIsMCUMode;
uint64_t m_last_adb_time;
@ -63,7 +59,7 @@ private:
int32_t m_adb_listenreg, m_adb_listenaddr, m_adb_last_talk, m_adb_srq_switch;
int32_t m_adb_stream_ptr;
int32_t m_adb_linestate;
u8 m_adb_buffer[257], m_last_kbd[2], m_last_mouse[2];
u8 m_adb_buffer[257], m_last_kbd[2], m_last_mouse[2], m_keyboard_handler, m_mouse_handler;
bool m_adb_srqflag;
int m_adb_linein;