Previous 15994 Revisions Next

r3697 Thursday 27th November, 2008 at 23:40:43 UTC by R. Belmont
More improvements to Mac ADB, setting up for having a keyboard.
[src/mess/machine]mac.c

src/mess/machine/mac.c
r3696r3697
12531253
12541254// ADB mouse state
12551255static int adb_mouseaddr = 3;
1256static int adb_lastmousex, adb_lastmousey;
1256static int adb_lastmousex, adb_lastmousey, adb_mouse_wanted_srq, adb_mouse_initialized;
12571257
1258// ADB keyboard state
1259static int adb_keybaddr = 2;
1260static int adb_keybinitialized, adb_keyb_wanted_srq;
1261
12581262#if LOG_ADB
12591263static const char *adb_statenames[4] = { "NEW", "EVEN", "ODD", "IDLE" };
12601264#endif
12611265
1266static void mac_adb_pollmouse(running_machine *machine)
1267{
1268   int NewX, NewY;
1269
1270   NewX = input_port_read(machine, "MOUSE2");
1271   NewY = input_port_read(machine, "MOUSE1");
1272
1273   if ((NewX != adb_lastmousex) || (NewY != adb_lastmousey))
1274   {
1275      adb_mouse_wanted_srq = 1;
1276   }
1277}
1278
12621279static void mac_adb_accummouse( running_machine *machine, UINT8 *MouseX, UINT8 *MouseY )
12631280{
12641281   int MouseCountX = 0, MouseCountY = 0;
r3696r3697
12971314      adb_lastmousey = NewY;
12981315   }
12991316
1317   adb_mouse_wanted_srq = 0;
1318
13001319   *MouseX = (UINT8)MouseCountX;
13011320   *MouseY = (UINT8)MouseCountY;
13021321}
r3696r3697
13661385                     adb_buffer[0] = 0x60 | ((adb_mouseaddr<<8)&0xf);   // SRQ enable, no exceptional event
13671386                     adb_buffer[1] = 0x01;   // handler 1
13681387                     adb_datasize = 2;
1388
1389                     adb_mouse_initialized = 1;
13691390                     break;
13701391
13711392                  default:
13721393                     break;
13731394               }
13741395            }
1396            else if (addr == adb_keybaddr)
1397            {
1398//               printf("Talking to keyboard, register %x\n", reg);
1399
1400               switch (reg)
1401               {
1402                  // read keyboard
1403                  case 0:   
1404                     adb_buffer[0] = adb_buffer[1] = 0x80;     // nothing pressed
1405                     adb_datasize = 2;
1406                     break;
1407
1408                  // read modifier keys
1409                  case 2:
1410                     adb_buffer[0] = 0xff;   // nothing pressed
1411                     adb_buffer[1] = 0;
1412                     adb_datasize = 2;
1413                     break;
1414
1415                  // get ID/handler
1416                  case 3:
1417                     adb_buffer[0] = 0x60 | ((adb_keybaddr<<8)&0xf);   // SRQ enable, no exceptional event
1418                     adb_buffer[1] = 0x01;   // handler 1
1419                     adb_datasize = 2;
1420
1421                     adb_keybinitialized = 1;
1422                     break;
1423
1424                  default:
1425                     break;
1426               }
1427            }
1428
1429            // if the mouse has new data and it's not what we're polling, yank SRQ
1430            if ((addr != adb_mouseaddr) && (adb_mouse_initialized))
1431            {
1432               mac_adb_pollmouse(machine);
1433            }
13751434            break;
13761435      }
13771436
r3696r3697
14801539   }
14811540}
14821541
1542static void adb_vblank(running_machine *machine)
1543{
1544   // if any device has a service request, show it on the VIA
1545   // (no need to actually generate an IRQ, the Mac will see it)
1546   if ((adb_mouse_wanted_srq) || (adb_keyb_wanted_srq))
1547   {
1548      adb_irq_pending = 1;
1549   }
1550   else
1551   {
1552      adb_irq_pending = 0;
1553   }
1554}
1555
14831556static void adb_reset(void)
14841557{
14851558   adb_irq_pending = 0;      // no interrupt
r3696r3697
14951568   // mouse
14961569   adb_mouseaddr = 3;
14971570   adb_lastmousex = adb_lastmousey = 0;
1571   adb_mouse_wanted_srq = 0;
1572   adb_mouse_initialized = 0;
1573
1574   // keyboard
1575   adb_keybaddr = 2;
1576   adb_keyb_wanted_srq = 0;
1577   adb_keybinitialized = 0;
14981578}
14991579
15001580/* *************************************************************************
r3696r3697
18261906{
18271907   static int irq_count = 0, ca1_data = 0, ca2_data = 0;
18281908
1909   /* handle ADB keyboard/mouse */
1910   if (has_adb())
1911   {
1912      adb_vblank(machine);
1913   }
1914
18291915   /* handle keyboard */
18301916   if (kbd_comm == TRUE)
18311917   {

Previous 15994 Revisions Next


© 1998-2018 The MESS Team