Previous 15994 Revisions Next

r9562 Saturday 13th November, 2010 at 03:37:43 UTC by R. Belmont
[MAC] More C++ conversion & improved emulation of V8, Eagle, and Sonora ASICs
[src/mess/drivers]mac.c
[src/mess/includes]mac.h
[src/mess/machine]mac.c
[src/mess/video]mac.c

src/mess/machine/mac.c
r9561r9562
15141514 * ADB (Mac II-style)
15151515 * *************************************************************************/
15161516
1517// ADB mouse state
1518static int adb_mouseaddr = 3;
1519static int adb_lastmousex, adb_lastmousey, adb_lastbutton, adb_mouse_initialized;
1520
1521// ADB keyboard state
1522static int adb_keybaddr = 2;
1523static int adb_keybinitialized, adb_currentkeys[2], adb_modifiers;
1524
15251517#if LOG_ADB
15261518static const char *const adb_statenames[4] = { "NEW", "EVEN", "ODD", "IDLE" };
15271519#endif
15281520
1529static int mac_adb_pollkbd(running_machine *machine, int update)
1521int mac_state::adb_pollkbd(running_machine *machine, int update)
15301522{
15311523   int i, j, keybuf, report, codes[2], result;
15321524   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5" };
1533   mac_state *mac = machine->driver_data<mac_state>();
15341525
15351526   codes[0] = codes[1] = 0x80;   // key up
15361527   report = result = 0;
r9561r9562
15401531      keybuf = input_port_read(machine, keynames[i]);
15411532
15421533      // any changes in this row?
1543      if ((keybuf != mac->m_key_matrix[i]) && (report < 2))
1534      if ((keybuf != m_key_matrix[i]) && (report < 2))
15441535      {
15451536         // check each column bit
15461537         for (j=0; j<16; j++)
15471538         {
1548            if (((keybuf ^ mac->m_key_matrix[i]) >> j) & 1)
1539            if (((keybuf ^ m_key_matrix[i]) >> j) & 1)
15491540            {
1550               // update mac->m_key_matrix
1541               // update m_key_matrix
15511542               if (update)
15521543               {
1553                  mac->m_key_matrix[i] = (mac->m_key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j));
1544                  m_key_matrix[i] = (m_key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j));
15541545               }
15551546
15561547               codes[report] = (i<<4)|j;
r9561r9562
15681559                  {
15691560                     if (codes[report] & 0x80)
15701561                     {
1571                        adb_modifiers &= ~0x20;
1562                        m_adb_modifiers &= ~0x20;
15721563                     }
15731564                     else
15741565                     {
1575                        adb_modifiers |= 0x20;
1566                        m_adb_modifiers |= 0x20;
15761567                     }
15771568                  }
15781569                  if (((i<<4)|j) == 0x36)
15791570                  {
15801571                     if (codes[report] & 0x80)
15811572                     {
1582                        adb_modifiers &= ~0x8;
1573                        m_adb_modifiers &= ~0x8;
15831574                     }
15841575                     else
15851576                     {
1586                        adb_modifiers |= 0x08;
1577                        m_adb_modifiers |= 0x08;
15871578                     }
15881579                  }
15891580                  if (((i<<4)|j) == 0x38)
15901581                  {
15911582                     if (codes[report] & 0x80)
15921583                     {
1593                        adb_modifiers &= ~0x4;
1584                        m_adb_modifiers &= ~0x4;
15941585                     }
15951586                     else
15961587                     {
1597                        adb_modifiers |= 0x04;
1588                        m_adb_modifiers |= 0x04;
15981589                     }
15991590                  }
16001591                  if (((i<<4)|j) == 0x3a)
16011592                  {
16021593                     if (codes[report] & 0x80)
16031594                     {
1604                        adb_modifiers &= ~0x2;
1595                        m_adb_modifiers &= ~0x2;
16051596                     }
16061597                     else
16071598                     {
1608                        adb_modifiers |= 0x02;
1599                        m_adb_modifiers |= 0x02;
16091600                     }
16101601                  }
16111602                  if (((i<<4)|j) == 0x37)
16121603                  {
16131604                     if (codes[report] & 0x80)
16141605                     {
1615                        adb_modifiers &= ~0x1;
1606                        m_adb_modifiers &= ~0x1;
16161607                     }
16171608                     else
16181609                     {
1619                        adb_modifiers |= 0x01;
1610                        m_adb_modifiers |= 0x01;
16201611                     }
16211612                  }
16221613               }
r9561r9562
16411632//  printf("ADB keyboard: update %d keys %02x %02x\n", update, codes[0], codes[1]);
16421633
16431634   // figure out if there was a change
1644   if ((adb_currentkeys[0] != codes[0]) || (adb_currentkeys[1] != codes[1]))
1635   if ((m_adb_currentkeys[0] != codes[0]) || (m_adb_currentkeys[1] != codes[1]))
16451636   {
16461637      result = 1;
16471638
16481639      // if we want to update the current read, do so
16491640      if (update)
16501641      {
1651         adb_currentkeys[0] = codes[0];
1652         adb_currentkeys[1] = codes[1];
1642         m_adb_currentkeys[0] = codes[0];
1643         m_adb_currentkeys[1] = codes[1];
16531644      }
16541645   }
16551646
16561647   return result;
16571648}
16581649
1659static int mac_adb_pollmouse(running_machine *machine)
1650int mac_state::adb_pollmouse(running_machine *machine)
16601651{
16611652   int NewX, NewY, NewButton;
16621653
1663   if (!adb_mouse_initialized)
1654   if (!m_adb_mouse_initialized)
16641655   {
16651656      return 0;
16661657   }
r9561r9562
16691660   NewX = input_port_read(machine, "MOUSE2");
16701661   NewY = input_port_read(machine, "MOUSE1");
16711662
1672   if ((NewX != adb_lastmousex) || (NewY != adb_lastmousey) || (NewButton != adb_lastbutton))
1663   if ((NewX != m_adb_lastmousex) || (NewY != m_adb_lastmousey) || (NewButton != m_adb_lastbutton))
16731664   {
16741665      return 1;
16751666   }
r9561r9562
16771668   return 0;
16781669}
16791670
1680static void mac_adb_accummouse( running_machine *machine, UINT8 *MouseX, UINT8 *MouseY )
1671void mac_state::adb_accummouse( running_machine *machine, UINT8 *MouseX, UINT8 *MouseY )
16811672{
16821673   int MouseCountX = 0, MouseCountY = 0;
16831674   int NewX, NewY;
r9561r9562
16861677   NewY = input_port_read(machine, "MOUSE1");
16871678
16881679   /* see if it moved in the x coord */
1689   if (NewX != adb_lastmousex)
1680   if (NewX != m_adb_lastmousex)
16901681   {
1691      int diff = NewX - adb_lastmousex;
1682      int diff = NewX - m_adb_lastmousex;
16921683
16931684      /* check for wrap */
16941685      if (diff > 0x80)
r9561r9562
16971688         diff = -0x100-diff;
16981689
16991690      MouseCountX += diff;
1700      adb_lastmousex = NewX;
1691      m_adb_lastmousex = NewX;
17011692   }
17021693
17031694   /* see if it moved in the y coord */
1704   if (NewY != adb_lastmousey)
1695   if (NewY != m_adb_lastmousey)
17051696   {
1706      int diff = NewY - adb_lastmousey;
1697      int diff = NewY - m_adb_lastmousey;
17071698
17081699      /* check for wrap */
17091700      if (diff > 0x80)
r9561r9562
17121703         diff = -0x100-diff;
17131704
17141705      MouseCountY += diff;
1715      adb_lastmousey = NewY;
1706      m_adb_lastmousey = NewY;
17161707   }
17171708
1718   adb_lastbutton = input_port_read(machine, "MOUSE0") & 0x01;
1709   m_adb_lastbutton = input_port_read(machine, "MOUSE0") & 0x01;
17191710
17201711   *MouseX = (UINT8)MouseCountX;
17211712   *MouseY = (UINT8)MouseCountY;
17221713}
17231714
1724static void mac_adb_talk(running_machine *machine)
1715void mac_state::adb_talk(running_machine *machine)
17251716{
17261717   int addr, reg;
1727   mac_state *mac = machine->driver_data<mac_state>();
17281718
1729   addr = (mac->m_adb_command>>4);
1730   reg = (mac->m_adb_command & 3);
1719   addr = (m_adb_command>>4);
1720   reg = (m_adb_command & 3);
17311721
1732//  printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", mac->m_adb_command, (mac->m_adb_command>>2)&3, addr, reg, adb_mouseaddr, adb_keybaddr);
1722//  printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", mac->m_adb_command, (mac->m_adb_command>>2)&3, addr, reg, m_adb_mouseaddr, m_adb_keybaddr);
17331723
1734   if (mac->m_adb_waiting_cmd)
1724   if (m_adb_waiting_cmd)
17351725   {
1736      switch ((mac->m_adb_command>>2)&3)
1726      switch ((m_adb_command>>2)&3)
17371727      {
17381728         case 0:
17391729         case 1:
r9561r9562
17431733                  #if LOG_ADB
17441734                  printf("ADB RESET: reg %x address %x\n", reg, addr);
17451735                  #endif
1746                  mac->m_adb_direction = 0;
1747                  mac->m_adb_send = 0;
1736                  m_adb_direction = 0;
1737                  m_adb_send = 0;
17481738                  break;
17491739
17501740               case ADB_CMD_FLUSH:
r9561r9562
17521742                  printf("ADB FLUSH: reg %x address %x\n", reg, addr);
17531743                  #endif
17541744
1755                  mac->m_adb_direction = 0;
1756                  mac->m_adb_send = 0;
1745                  m_adb_direction = 0;
1746                  m_adb_send = 0;
17571747                  break;
17581748
17591749               default:   // reserved/unused
r9561r9562
17661756            printf("ADB LISTEN: reg %x address %x\n", reg, addr);
17671757            #endif
17681758
1769            mac->m_adb_direction = 1;   // input from Mac
1770            mac->m_adb_listenreg = reg;
1771            mac->m_adb_listenaddr = addr;
1772            mac->m_adb_command = 0;
1759            m_adb_direction = 1;   // input from Mac
1760            m_adb_listenreg = reg;
1761            m_adb_listenaddr = addr;
1762            m_adb_command = 0;
17731763            break;
17741764
17751765         case 3: // talk
r9561r9562
17781768            #endif
17791769
17801770            // keep track of what device the Mac last TALKed to
1781            mac->m_adb_last_talk = addr;
1771            m_adb_last_talk = addr;
17821772
1783            mac->m_adb_direction = 0;    // output to Mac
1784            if (addr == adb_mouseaddr)
1773            m_adb_direction = 0;    // output to Mac
1774            if (addr == m_adb_mouseaddr)
17851775            {
17861776               UINT8 mouseX, mouseY;
17871777
r9561r9562
17931783               {
17941784                  // read mouse
17951785                  case 0:
1796                     if (mac->m_adb_srq_switch)
1786                     if (m_adb_srq_switch)
17971787                     {
1798                        mac->m_adb_srq_switch = 0;
1788                        m_adb_srq_switch = 0;
17991789                        mouseX = mouseY = 0;
18001790                     }
18011791                     else
18021792                     {
1803                        mac_adb_accummouse(machine, &mouseX, &mouseY);
1793                        adb_accummouse(machine, &mouseX, &mouseY);
18041794                     }
1805                     mac->m_adb_buffer[0] = (adb_lastbutton & 0x01) ? 0x00 : 0x80;
1806                     mac->m_adb_buffer[0] |= mouseX & 0x7f;
1807                     mac->m_adb_buffer[1] = mouseY & 0x7f;
1808                     mac->m_adb_datasize = 2;
1795                     m_adb_buffer[0] = (m_adb_lastbutton & 0x01) ? 0x00 : 0x80;
1796                     m_adb_buffer[0] |= mouseX & 0x7f;
1797                     m_adb_buffer[1] = mouseY & 0x7f;
1798                     m_adb_datasize = 2;
18091799                     break;
18101800
18111801                  // get ID/handler
18121802                  case 3:
1813                     mac->m_adb_buffer[0] = 0x60 | ((adb_mouseaddr<<8)&0xf);   // SRQ enable, no exceptional event
1814                     mac->m_adb_buffer[1] = 0x01;   // handler 1
1815                     mac->m_adb_datasize = 2;
1803                     m_adb_buffer[0] = 0x60 | ((m_adb_mouseaddr<<8)&0xf);   // SRQ enable, no exceptional event
1804                     m_adb_buffer[1] = 0x01;   // handler 1
1805                     m_adb_datasize = 2;
18161806
1817                     adb_mouse_initialized = 1;
1807                     m_adb_mouse_initialized = 1;
18181808                     break;
18191809
18201810                  default:
18211811                     break;
18221812               }
18231813            }
1824            else if (addr == adb_keybaddr)
1814            else if (addr == m_adb_keybaddr)
18251815            {
18261816               #if LOG_ADB
18271817               printf("Talking to keyboard, register %x\n", reg);
r9561r9562
18311821               {
18321822                  // read keyboard
18331823                  case 0:
1834                     if (mac->m_adb_srq_switch)
1824                     if (m_adb_srq_switch)
18351825                     {
1836                        mac->m_adb_srq_switch = 0;
1826                        m_adb_srq_switch = 0;
18371827                     }
18381828                     else
18391829                     {
1840                        mac_adb_pollkbd(machine, 1);
1830                        adb_pollkbd(machine, 1);
18411831                     }
1842//                          printf("keyboard = %02x %02x\n", adb_currentkeys[0], adb_currentkeys[1]);
1843                     mac->m_adb_buffer[0] = adb_currentkeys[1];
1844                     mac->m_adb_buffer[1] = adb_currentkeys[0];
1845                     mac->m_adb_datasize = 2;
1832//                          printf("keyboard = %02x %02x\n", m_adb_currentkeys[0], m_adb_currentkeys[1]);
1833                     m_adb_buffer[0] = m_adb_currentkeys[1];
1834                     m_adb_buffer[1] = m_adb_currentkeys[0];
1835                     m_adb_datasize = 2;
18461836                     break;
18471837
18481838                  // read modifier keys
18491839                  case 2:
1850                     mac_adb_pollkbd(machine, 1);
1851                     mac->m_adb_buffer[0] = adb_modifiers;   // nothing pressed
1852                     mac->m_adb_buffer[1] = 0;
1853                     mac->m_adb_datasize = 2;
1840                     adb_pollkbd(machine, 1);
1841                     m_adb_buffer[0] = m_adb_modifiers;   // nothing pressed
1842                     m_adb_buffer[1] = 0;
1843                     m_adb_datasize = 2;
18541844                     break;
18551845
18561846                  // get ID/handler
18571847                  case 3:
1858                     mac->m_adb_buffer[0] = 0x60 | ((adb_keybaddr<<8)&0xf);   // SRQ enable, no exceptional event
1859                     mac->m_adb_buffer[1] = 0x01;   // handler 1
1860                     mac->m_adb_datasize = 2;
1848                     m_adb_buffer[0] = 0x60 | ((m_adb_keybaddr<<8)&0xf);   // SRQ enable, no exceptional event
1849                     m_adb_buffer[1] = 0x01;   // handler 1
1850                     m_adb_datasize = 2;
18611851
1862                     adb_keybinitialized = 1;
1852                     m_adb_keybinitialized = 1;
18631853                     break;
18641854
18651855                  default:
r9561r9562
18711861               #if LOG_ADB
18721862               printf("ADB: talking to unconnected device\n");
18731863               #endif
1874               mac->m_adb_buffer[0] = mac->m_adb_buffer[1] = 0;
1875               mac->m_adb_datasize = 0;
1864               m_adb_buffer[0] = m_adb_buffer[1] = 0;
1865               m_adb_datasize = 0;
18761866            }
18771867            break;
18781868      }
18791869
1880      mac->m_adb_waiting_cmd = 0;
1870      m_adb_waiting_cmd = 0;
18811871   }
18821872   else
18831873   {
18841874      #if LOG_ADB
1885      printf("Got LISTEN data %x for device %x reg %x\n", mac->m_adb_command, mac->m_adb_listenaddr, mac->m_adb_listenreg);
1875      printf("Got LISTEN data %x for device %x reg %x\n", m_adb_command, m_adb_listenaddr, m_adb_listenreg);
18861876      #endif
18871877
1888      if (mac->m_adb_listenaddr == adb_mouseaddr)
1878      if (m_adb_listenaddr == m_adb_mouseaddr)
18891879      {
1890         if ((mac->m_adb_listenreg == 3) && (mac->m_adb_command > 0) && (mac->m_adb_command < 16))
1880         if ((m_adb_listenreg == 3) && (m_adb_command > 0) && (m_adb_command < 16))
18911881         {
18921882            #if LOG_ADB
1893            printf("MOUSE: moving to address %x\n", mac->m_adb_command);
1883            printf("MOUSE: moving to address %x\n", m_adb_command);
18941884            #endif
1895            adb_mouseaddr = mac->m_adb_command&0x0f;
1885            m_adb_mouseaddr = m_adb_command&0x0f;
18961886         }
18971887      }
1898      else if (mac->m_adb_listenaddr == adb_keybaddr)
1888      else if (m_adb_listenaddr == m_adb_keybaddr)
18991889      {
1900         if ((mac->m_adb_listenreg == 3) && (mac->m_adb_command > 0) && (mac->m_adb_command < 16))
1890         if ((m_adb_listenreg == 3) && (m_adb_command > 0) && (m_adb_command < 16))
19011891         {
19021892            #if LOG_ADB
1903            printf("KEYBOARD: moving to address %x\n", mac->m_adb_command);
1893            printf("KEYBOARD: moving to address %x\n", m_adb_command);
19041894            #endif
1905            adb_keybaddr = mac->m_adb_command&0x0f;
1895            m_adb_keybaddr = m_adb_command&0x0f;
19061896         }
19071897      }
19081898   }
r9561r9562
19251915
19261916      if ((mac->m_adb_direction) && (ADB_IS_BITBANG))
19271917      {
1928         mac_adb_talk(machine);
1918         mac->adb_talk(machine);
19291919      }
19301920      else if (ADB_IS_EGRET)
19311921      {
r9561r9562
20912081   timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
20922082}
20932083
2084static void mac_egret_response_adb(mac_state *mac, int type, int flag, int cmd, int extra)
2085{
2086   mac->m_adb_send = 0xaa;
2087   mac->m_adb_buffer[4] = extra;
2088   mac->m_adb_buffer[3] = type;
2089   mac->m_adb_buffer[2] = flag;
2090   mac->m_adb_buffer[1] = cmd;
2091   mac->m_adb_state |= 1;
2092   mac->m_adb_timer_ticks = 8;
2093   mac->m_adb_datasize = 4;
2094   timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
2095}
2096
20942097static void mac_egret_response_read_pram(mac_state *mac, int cmd, int addr)
20952098{
20962099   mac->m_adb_datasize = 4;
r9561r9562
22392242         mac_egret_response_std(mac, 1, 0, 0x0e);
22402243         break;
22412244
2245      case 0x19: // set device list bitmap
2246         #if LOG_ADB || LOG_ADB_MCU_CMD
2247         printf("ADB: Egret set device list bitmap %02x%02x\n", mac->m_adb_buffer[2], mac->m_adb_buffer[3]);
2248         #endif
2249
2250         mac_egret_response_std(mac, 1, 0, 0x19);
2251         break;
2252
22422253      case 0x1b: // set one-second interrupt
22432254         #if LOG_ADB || LOG_ADB_MCU_CMD
22442255         if (mac->m_adb_buffer[2])
r9561r9562
23442355                     #if LOG_ADB || LOG_ADB_MCU_CMD
23452356                     printf("Egret: ADB Reset\n");
23462357                     #endif
2347                     mac_egret_response_std(mac, 0, 0, 0);
2358                     mac_egret_response_adb(mac, 0, 0, 0, 0);
23482359                     break;
23492360
23502361                  case 1:      // flush
23512362                     #if LOG_ADB || LOG_ADB_MCU_CMD
2352                     printf("Egret: ADB Reset\n");
2363                     printf("Egret: ADB Flush\n");
23532364                     #endif
2354                     mac_egret_response_std(mac, 1, 0, 0);
2365                     mac_egret_response_std(mac, 1, 1, 0);
23552366                     break;
23562367
23572368                  default:
2358                     printf("Egret: Unhandled ADB command %x\n", mac->m_adb_buffer[1]);
2369                     switch ((mac->m_adb_buffer[1]>>2)&3)
2370                     {
2371                        case 2:   // ADB listen
2372                           #if LOG_ADB || LOG_ADB_MCU_CMD
2373                           printf("Egret: ADB listen to device %d\n", mac->m_adb_buffer[1]>>4);
2374                           #endif
2375                           mac_egret_response_adb(mac, 0, 2, 0, 0);
2376                           break;
2377
2378                        case 3: // ADB talk
2379                           #if LOG_ADB || LOG_ADB_MCU_CMD
2380                           printf("Egret: ADB talk to device %d\n", mac->m_adb_buffer[1]>>4);
2381                           #endif
2382                           mac_egret_response_adb(mac, 0, 2, 0, 0);
2383                           break;
2384                     }
2385
2386                     #if LOG_ADB || LOG_ADB_MCU_CMD
2387                     printf("Egret: Unhandled ADB command %02x\n", mac->m_adb_buffer[1]);
2388                     #endif
23592389                     mac->m_adb_datasize = 0;
23602390                     break;
23612391
r9561r9562
24782508{
24792509   if (m_adb_state == ADB_STATE_IDLE)
24802510   {
2481      if (mac_adb_pollmouse(machine))
2511      if (adb_pollmouse(machine))
24822512      {
24832513         // if the mouse was the last TALK, we can just send the new data
24842514         // otherwise we need to pull SRQ
2485         if (m_adb_last_talk == adb_mouseaddr)
2515         if (m_adb_last_talk == m_adb_mouseaddr)
24862516         {
24872517            // repeat last TALK to get updated data
24882518            m_adb_waiting_cmd = 1;
2489            mac_adb_talk(machine);
2519            adb_talk(machine);
24902520
24912521            m_adb_timer_ticks = 8;
24922522            timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
r9561r9562
25002530            m_adb_srq_switch = 1;
25012531         }
25022532      }
2503      else if (mac_adb_pollkbd(machine, 0))
2533      else if (adb_pollkbd(machine, 0))
25042534      {
2505         if (m_adb_last_talk == adb_keybaddr)
2535         if (m_adb_last_talk == m_adb_keybaddr)
25062536         {
25072537            // repeat last TALK to get updated data
25082538            m_adb_waiting_cmd = 1;
2509            mac_adb_talk(machine);
2539            adb_talk(machine);
25102540
25112541            m_adb_timer_ticks = 8;
25122542            timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0);
r9561r9562
25452575   m_adb_last_talk = -1;
25462576
25472577   // mouse
2548   adb_mouseaddr = 3;
2549   adb_lastmousex = adb_lastmousey = adb_lastbutton = 0;
2550   adb_mouse_initialized = 0;
2578   m_adb_mouseaddr = 3;
2579   m_adb_lastmousex = m_adb_lastmousey = m_adb_lastbutton = 0;
2580   m_adb_mouse_initialized = 0;
25512581
25522582   // keyboard
2553   adb_keybaddr = 2;
2554   adb_keybinitialized = 0;
2555   adb_currentkeys[0] = adb_currentkeys[1] = 0x80;
2556   adb_modifiers = 0;
2583   m_adb_keybaddr = 2;
2584   m_adb_keybinitialized = 0;
2585   m_adb_currentkeys[0] = m_adb_currentkeys[1] = 0x80;
2586   m_adb_modifiers = 0;
25572587   for (i=0; i<7; i++)
25582588   {
25592589      m_key_matrix[i] = 0;
r9561r9562
30263056   // stop 60.15 Hz timer
30273057   timer_adjust_oneshot(m_6015_timer, attotime_never, 0);
30283058
3029   // start 60.15 Hz timer for IIci/IIsi (and eventually others)
3030   if ((m_model == MODEL_MAC_IICI) || (m_model == MODEL_MAC_IISI))
3059   // start 60.15 Hz timer for most systems
3060   if (((m_model >= MODEL_MAC_IICI) && (m_model <= MODEL_MAC_IIVI)) || (m_model >= MODEL_MAC_LC))
30313061   {
30323062      timer_adjust_periodic(m_6015_timer, ATTOTIME_IN_HZ(60.15), 0, ATTOTIME_IN_HZ(60.15));
30333063   }
src/mess/video/mac.c
r9561r9562
324324{
325325}
326326
327VIDEO_RESET(maceagle)
328{
329   mac_state *mac = machine->driver_data<mac_state>();
330
331   mac->m_rbv_montype = 32;
332   mac->m_rbv_palette[0xfe] = 0xffffff;
333   mac->m_rbv_palette[0xff] = 0;
334}
335
327336VIDEO_RESET(macrbv)
328337{
329338   mac_state *mac = machine->driver_data<mac_state>();
r9561r9562
344353   visarea.min_x = 0;
345354   visarea.min_y = 0;
346355
347   if (mac->m_model == MODEL_MAC_CLASSIC_II)
356   mac->m_rbv_montype = input_port_read_safe(machine, "MONTYPE", 2);
357   switch (mac->m_rbv_montype)
348358   {
349      mac->m_rbv_montype = 32;
350      visarea.max_x = MAC_H_VIS-1;
351      visarea.max_y = MAC_V_VIS-1;
352           htotal = MAC_H_TOTAL;
353      vtotal = MAC_V_TOTAL;
354      framerate = 60.15;
355   }
356   else
357   {
358      mac->m_rbv_montype = input_port_read_safe(machine, "MONTYPE", 2);
359      switch (mac->m_rbv_montype)
360      {
361         case 1:   // 15" portrait display
362            visarea.max_x = 640-1;
363            visarea.max_y = 870-1;
364                 htotal = 832;
365            vtotal = 918;
366            framerate = 75.0;
367            break;
359      case 1:   // 15" portrait display
360         visarea.max_x = 640-1;
361         visarea.max_y = 870-1;
362              htotal = 832;
363         vtotal = 918;
364         framerate = 75.0;
365         break;
368366
369         case 2: // 12" RGB
370            visarea.max_x = 512-1;
371            visarea.max_y = 384-1;
372                 htotal = 640;
373            vtotal = 407;
374            framerate = 60.15;
375            break;
367      case 2: // 12" RGB
368         visarea.max_x = 512-1;
369         visarea.max_y = 384-1;
370              htotal = 640;
371         vtotal = 407;
372         framerate = 60.15;
373         break;
376374
377         case 6: // 13" RGB
378         default:
379            visarea.max_x = 640-1;
380            visarea.max_y = 480-1;
381                 htotal = 800;
382            vtotal = 525;
383            framerate = 59.94;
384            break;
385      }
375      case 6: // 13" RGB
376      default:
377         visarea.max_x = 640-1;
378         visarea.max_y = 480-1;
379              htotal = 800;
380         vtotal = 525;
381         framerate = 59.94;
382         break;
386383   }
387384
388//   printf("RBV reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate);
385//       printf("RBV reset: monitor is %dx%d @ %f Hz\n", visarea.max_x+1, visarea.max_y+1, framerate);
389386   machine->primary_screen->configure(htotal, vtotal, visarea, HZ_TO_ATTOSECONDS(framerate));
390387}
391388
r9561r9562
432429   UINT32 *scanline;
433430   int x, y, hres, vres;
434431   mac_state *mac = screen->machine->driver_data<mac_state>();
432   UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
435433
436434   switch (mac->m_rbv_montype)
437435   {
438436      case 32: // classic II built-in display
439437         hres = MAC_H_VIS;
440438         vres = MAC_V_VIS;
439         vram8 += 0x1f9a80;   // Classic II apparently doesn't use VRAM?
441440         break;
442441
443442      case 1:   // 15" portrait display
r9561r9562
461460   {
462461      case 0:   // 1bpp
463462      {
464         UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
465463         UINT8 pixels;
466464
467465         for (y = 0; y < vres; y++)
r9561r9562
486484
487485      case 1:   // 2bpp
488486      {
489         UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
490487         UINT8 pixels;
491488
492489         for (y = 0; y < vres; y++)
r9561r9562
507504
508505      case 2: // 4bpp
509506      {
510         UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
511507         UINT8 pixels;
512508
513509         for (y = 0; y < vres; y++)
r9561r9562
527523
528524      case 3: // 8bpp
529525      {
530         UINT8 *vram8 = (UINT8 *)messram_get_ptr(screen->machine->device("messram"));
531526         UINT8 pixels;
532527         
533528         for (y = 0; y < vres; y++)
r9561r9562
578573         UINT8 *vram8 = (UINT8 *)mac->m_rbv_vram;
579574         UINT8 pixels;
580575
581         for (y = 0; y < 480; y++)
576
577         if (mac->m_rbv_type == RBV_TYPE_SONORA)
582578         {
583            scanline = BITMAP_ADDR32(bitmap, y, 0);
584            for (x = 0; x < 640; x+=8)
579            for (y = 0; y < 480; y++)
585580            {
586               pixels = vram8[(y * 80) + ((x/8)^3)];
581               scanline = BITMAP_ADDR32(bitmap, y, 0);
582               for (x = 0; x < 640; x+=8)
583               {
584                  pixels = vram8[(y * 80) + ((x/8)^3)];
587585
588               *scanline++ = mac->m_rbv_palette[0xfe|(pixels>>7)];
589               *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>6)&1)];
590               *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>5)&1)];
591               *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>4)&1)];
592               *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>3)&1)];
593               *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>2)&1)];
594               *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>1)&1)];
595               *scanline++ = mac->m_rbv_palette[0xfe|(pixels&1)];
586                  *scanline++ = mac->m_rbv_palette[0x7f|(pixels&0x80)];
587                  *scanline++ = mac->m_rbv_palette[0x7f|((pixels<<1)&0x80)];
588                  *scanline++ = mac->m_rbv_palette[0x7f|((pixels<<2)&0x80)];
589                  *scanline++ = mac->m_rbv_palette[0x7f|((pixels<<3)&0x80)];
590                  *scanline++ = mac->m_rbv_palette[0x7f|((pixels<<4)&0x80)];
591                  *scanline++ = mac->m_rbv_palette[0x7f|((pixels<<5)&0x80)];
592                  *scanline++ = mac->m_rbv_palette[0x7f|((pixels<<6)&0x80)];
593                  *scanline++ = mac->m_rbv_palette[0x7f|((pixels<<7)&0x80)];
594               }
596595            }
597596         }
597         else
598         {
599            for (y = 0; y < 480; y++)
600            {
601               scanline = BITMAP_ADDR32(bitmap, y, 0);
602               for (x = 0; x < 640; x+=8)
603               {
604                  pixels = vram8[(y * 80) + ((x/8)^3)];
605
606                  *scanline++ = mac->m_rbv_palette[0xfe|(pixels>>7)];
607                  *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>6)&1)];
608                  *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>5)&1)];
609                  *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>4)&1)];
610                  *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>3)&1)];
611                  *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>2)&1)];
612                  *scanline++ = mac->m_rbv_palette[0xfe|((pixels>>1)&1)];
613                  *scanline++ = mac->m_rbv_palette[0xfe|(pixels&1)];
614               }
615            }
616         }
598617      }
599618      break;
600619
src/mess/includes/mac.h
r9561r9562
155155VIDEO_UPDATE( macrbv );
156156VIDEO_UPDATE( macrbvvram );
157157VIDEO_RESET(macrbv);
158VIDEO_RESET(maceagle);
158159
159160void mac_set_screen_buffer( int buffer );
160161
r9561r9562
299300   void rtc_shift_data(int data);
300301   void vblank_irq(running_machine *machine);
301302   void rtc_incticks();
303   void adb_talk(running_machine *machine);
302304
303305   DECLARE_READ16_MEMBER ( mac_via_r );
304306   DECLARE_WRITE16_MEMBER ( mac_via_w );
r9561r9562
319321
320322   DECLARE_READ32_MEMBER( rbv_ramdac_r );
321323   DECLARE_WRITE32_MEMBER( rbv_ramdac_w );
324   DECLARE_WRITE32_MEMBER( ariel_ramdac_w );
322325   DECLARE_READ8_MEMBER( mac_sonora_vctl_r );
323326   DECLARE_WRITE8_MEMBER( mac_sonora_vctl_w );
324327   DECLARE_READ8_MEMBER ( mac_rbv_r );
r9561r9562
338341   void rtc_execute_cmd(int data);
339342   void adb_reset(running_machine *machine);
340343   void adb_vblank(running_machine *machine);
344   int adb_pollkbd(running_machine *machine, int update);
345   int adb_pollmouse(running_machine *machine);
346   void adb_accummouse( running_machine *machine, UINT8 *MouseX, UINT8 *MouseY );
347
348
349   // ADB mouse state
350   int m_adb_mouseaddr;
351   int m_adb_lastmousex, m_adb_lastmousey, m_adb_lastbutton, m_adb_mouse_initialized;
352
353   // ADB keyboard state
354   int m_adb_keybaddr;
355   int m_adb_keybinitialized, m_adb_currentkeys[2], m_adb_modifiers;
341356};
342357
343358#endif /* MAC_H_ */
src/mess/drivers/mac.c
r9561r9562
121121   }
122122}
123123
124WRITE32_MEMBER( mac_state::ariel_ramdac_w )   // this is for the "Ariel" style RAMDAC
125{
126   if (mem_mask == 0xff000000)
127   {
128      m_rbv_clutoffs = data>>24;
129      m_rbv_count = 0;
130   }
131   else if (mem_mask == 0x00ff0000)
132   {
133      m_rbv_colors[m_rbv_count++] = data>>16;
134
135      if (m_rbv_count == 3)
136      {
137         // for portrait display, force monochrome by using the blue channel
138         if (m_model != MODEL_MAC_CLASSIC_II)
139         {
140            // Color Classic has no MONTYPE so the safe read gets us 512x384, which is right
141            if (input_port_read_safe(space.machine, "MONTYPE", 2) == 1)
142            {
143               palette_set_color(space.machine, m_rbv_clutoffs, MAKE_RGB(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]));
144               m_rbv_palette[m_rbv_clutoffs] = MAKE_RGB(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]);
145               m_rbv_clutoffs++;
146               m_rbv_count = 0;
147            }
148            else
149            {
150               palette_set_color(space.machine, m_rbv_clutoffs, MAKE_RGB(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2]));
151               m_rbv_palette[m_rbv_clutoffs] = MAKE_RGB(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2]);
152               m_rbv_clutoffs++;
153               m_rbv_count = 0;
154            }
155         }
156      }
157   }
158   else if (mem_mask == 0x0000ff00)
159   {
160      // config reg
161//      printf("Ariel: %02x to config\n", (data>>8)&0xff);
162   }
163   else   // color key reg
164   {
165   }
166}
167
124168READ8_MEMBER( mac_state::mac_sonora_vctl_r )
125169{
126170   if (offset == 2)
r9561r9562
133177
134178WRITE8_MEMBER( mac_state::mac_sonora_vctl_w )
135179{
180//   printf("Sonora: %02x to vctl %x\n", data, offset);
136181   m_sonora_vctl[offset] = data;   
137182}
138183
r9561r9562
154199
155200      if (offset == 0x10)
156201      {
157         if (!m_rbv_immed10wr)
158         {
159            data &= ~0x38;
160            data |= (input_port_read_safe(space.machine, "MONTYPE", 2)<<3);
161         }
162         else
163         {
164            m_rbv_immed10wr = 0;
165         }
202         data &= ~0x38;
203         data |= (input_port_read_safe(space.machine, "MONTYPE", 2)<<3);
204//         printf("rbv_r montype: %02x (PC %x)\n", data, cpu_get_pc(space.cpu));
166205      }
167206
168207      // bit 7 of these registers always reads as 0 on RBV
r9561r9562
402441   AM_RANGE(0xf12060, 0xf12063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000)
403442   AM_RANGE(0xf14000, 0xf15fff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffffffff) AM_MIRROR(0x00f00000)
404443   AM_RANGE(0xf16000, 0xf17fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000)
405   AM_RANGE(0xf24000, 0xf24003) AM_READWRITE(rbv_ramdac_r, rbv_ramdac_w)
444   AM_RANGE(0xf24000, 0xf24003) AM_READWRITE(rbv_ramdac_r, ariel_ramdac_w)
406445   AM_RANGE(0xf26000, 0xf27fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff)   // VIA2 (V8)
407446   AM_RANGE(0xf40000, 0xfbffff) AM_RAM AM_BASE(m_rbv_vram)
408447ADDRESS_MAP_END
r9561r9562
412451
413452   AM_RANGE(0x50000000, 0x50001fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000)
414453   AM_RANGE(0x50004000, 0x50005fff) AM_READWRITE16(mac_scc_r, mac_scc_2_w, 0xffffffff) AM_MIRROR(0x00f00000)
454   AM_RANGE(0x50010000, 0x50011fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000)
455   AM_RANGE(0x50012060, 0x50012063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000)
415456   AM_RANGE(0x50014000, 0x50015fff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffffffff) AM_MIRROR(0x00f00000)
416457   AM_RANGE(0x50016000, 0x50017fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000)
417   AM_RANGE(0x50024000, 0x50024007) AM_WRITE( rbv_ramdac_w ) AM_MIRROR(0x00f00000)
458   AM_RANGE(0x50024000, 0x50025fff) AM_WRITE( ariel_ramdac_w ) AM_MIRROR(0x00f00000)
418459   AM_RANGE(0x50026000, 0x50027fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff) AM_MIRROR(0x00f00000)
419460   AM_RANGE(0x50028000, 0x50028003) AM_READWRITE8(mac_sonora_vctl_r, mac_sonora_vctl_w, 0xffffffff) AM_MIRROR(0x00f00000)
420461
r9561r9562
742783   MDRV_PALETTE_LENGTH(256)
743784
744785   MDRV_VIDEO_START(macv8)
786   MDRV_VIDEO_RESET(macrbv)
745787   MDRV_VIDEO_UPDATE(macrbvvram)
746788
747789   MDRV_RAM_MODIFY("messram")
r9561r9562
771813   MDRV_CPU_VBLANK_INT("screen", mac_rbv_vbl)
772814
773815   MDRV_VIDEO_START(macsonora)
816   MDRV_VIDEO_RESET(macrbv)
774817   MDRV_VIDEO_UPDATE(macrbvvram)
775818
776819   MDRV_RAM_MODIFY("messram")
r9561r9562
850893   MDRV_CPU_PROGRAM_MAP(maclc_map)
851894
852895   MDRV_VIDEO_START(macv8)
896   MDRV_VIDEO_RESET(maceagle)
853897   MDRV_VIDEO_UPDATE(macrbv)
854898
899   MDRV_SCREEN_MODIFY("screen")
900   MDRV_SCREEN_SIZE(MAC_H_TOTAL, MAC_V_TOTAL)
901   MDRV_SCREEN_VISIBLE_AREA(0, MAC_H_VIS-1, 0, MAC_V_VIS-1)
902
855903   MDRV_ASC_REPLACE("asc", C15M, ASC_TYPE_EAGLE, mac_asc_irq)
856904   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
857905   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
r9561r9562
874922   MDRV_VIDEO_UPDATE(macrbv)
875923
876924   MDRV_SCREEN_MODIFY("screen")
877   MDRV_DEFAULT_LAYOUT(layout_lcd)
878925   MDRV_SCREEN_SIZE(640, 870)
879926   MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
880927
r9561r9562
897944   MDRV_VIDEO_UPDATE(macrbv)
898945
899946   MDRV_SCREEN_MODIFY("screen")
900   MDRV_DEFAULT_LAYOUT(layout_lcd)
901947   MDRV_SCREEN_SIZE(640, 870)
902948   MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
903949
r9561r9562
925971   MDRV_PALETTE_LENGTH(256)
926972
927973   MDRV_VIDEO_START(macsonora)
974   MDRV_VIDEO_RESET(macrbv)
928975   MDRV_VIDEO_UPDATE(macrbv)
929976
930977   /* sound hardware */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team