Previous 15994 Revisions Next

r6211 Thursday 29th October, 2009 at 00:46:17 UTC by R. Belmont
[MAC] Improved ADB implementation to cooperate with driver in 6.0.8.
[src/mess/machine]mac.c

src/mess/machine/mac.c
r6210r6211
13651365
13661366// ADB mouse state
13671367static int adb_mouseaddr = 3;
1368static int adb_lastmousex, adb_lastmousey, adb_mouse_wanted_srq, adb_mouse_initialized;
1368static int adb_lastmousex, adb_lastmousey, adb_lastbutton, adb_mouse_wanted_srq, adb_mouse_initialized;
13691369
13701370// ADB keyboard state
13711371static int adb_keybaddr = 2;
r6210r6211
13771377
13781378static void mac_adb_pollmouse(running_machine *machine)
13791379{
1380   int NewX, NewY;
1380   int NewX, NewY, NewButton;
13811381
1382   NewButton = input_port_read(machine, "MOUSE0") & 0x01;
13821383   NewX = input_port_read(machine, "MOUSE2");
13831384   NewY = input_port_read(machine, "MOUSE1");
13841385
1385   if ((NewX != adb_lastmousex) || (NewY != adb_lastmousey))
1386   if ((NewX != adb_lastmousex) || (NewY != adb_lastmousey) || (NewButton != adb_lastbutton))
13861387   {
13871388      adb_mouse_wanted_srq = 1;
13881389   }
r6210r6211
14261427      adb_lastmousey = NewY;
14271428   }
14281429
1430   adb_lastbutton = input_port_read(machine, "MOUSE0") & 0x01;
1431
14291432   adb_mouse_wanted_srq = 0;
14301433
14311434   *MouseX = (UINT8)MouseCountX;
r6210r6211
14391442   addr = (adb_command>>4);
14401443   reg = (adb_command & 3);
14411444
1442//  printf("Mac sent %x\n", adb_command);
1445//   printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", adb_command, (adb_command>>2)&3, addr, reg, adb_mouseaddr, adb_keybaddr);
14431446
14441447   if (adb_waiting_cmd)
14451448   {
1449      const device_config *via_0 = devtag_get_device(machine, "via6522_0");
1450
14461451      switch ((adb_command>>2)&3)
14471452      {
14481453         case 0:
r6210r6211
14571462               case ADB_CMD_FLUSH:
14581463                  adb_direction = 0;
14591464                  adb_send = 0;
1465
1466                  adb_buffer[0] = 0xff;
1467                  adb_datasize = 1;
1468
1469                  // it's not documented how to respond, but yanking SRQ seems to work
1470                  adb_extclock ^= 1;
1471                  via_cb1_w(via_0, 0, adb_extclock);
1472                  adb_extclock ^= 1;
1473                  via_cb1_w(via_0, 0, adb_extclock);
14601474                  break;
14611475
14621476               default:   // reserved/unused
r6210r6211
15371551                     break;
15381552               }
15391553            }
1554            else
1555            {
1556//               printf("talking to unconnected device\n");
1557               adb_buffer[0] = adb_buffer[1] = 0xff;
1558               adb_datasize = 0;
1559            }
15401560
15411561            // if the mouse has new data and it's not what we're polling, yank SRQ
15421562            if ((addr != adb_mouseaddr) && (adb_mouse_initialized))
r6210r6211
15871607   ret = (adb_send & 0x80)>>7;
15881608   adb_send <<= 1;
15891609
1590//  printf("IN CB2 = %x\n", ret);
1610//   printf("IN CB2 = %x\n", ret);
15911611
15921612   return ret;
15931613}
r6210r6211
16161636            adb_command = adb_send = 0;
16171637            adb_direction = 1;   // Mac is shifting us a command
16181638            adb_waiting_cmd = 1;   // we're going to get a command
1639            timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
16191640            break;
16201641
16211642         case ADB_STATE_XFER_EVEN:
r6210r6211
16401661            }
16411662            else
16421663            {
1643               adb_send = 0;
1664               adb_send = 0xff;   // try pulling up?
16441665            }
1666            timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
16451667            break;
16461668
16471669         case ADB_STATE_IDLE:
1670            adb_send = 0xff;
16481671            break;
16491672      }
16501673
16511674      // no matter what, generate 8 clocks (should this happen on IDLE?)
1652      timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
1675//      timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
16531676   }
16541677}
16551678
r6210r6211
16591682   // (no need to actually generate an IRQ, the Mac will see it)
16601683   if ((adb_mouse_wanted_srq) || (adb_keyb_wanted_srq))
16611684   {
1685//      printf("ADB IRQ: kb %d ms %d\n", adb_keyb_wanted_srq, adb_mouse_wanted_srq);
16621686      adb_irq_pending = 1;
16631687   }
16641688   else
16651689   {
16661690      adb_irq_pending = 0;
1691      mac_adb_pollmouse(machine);
1692
1693      if ((adb_state == ADB_STATE_IDLE) && (adb_mouse_wanted_srq))
1694      {
1695         adb_timer_ticks = 8;
1696         timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
1697         adb_mouse_wanted_srq = 0;
1698      }
16671699   }
16681700}
16691701
r6210r6211
16811713
16821714   // mouse
16831715   adb_mouseaddr = 3;
1684   adb_lastmousex = adb_lastmousey = 0;
1716   adb_lastmousex = adb_lastmousey = adb_lastbutton = 0;
16851717   adb_mouse_wanted_srq = 0;
16861718   adb_mouse_initialized = 0;
16871719

Previous 15994 Revisions Next


© 1998-2018 The MESS Team