Previous 199869 Revisions Next

r18680 Tuesday 23rd October, 2012 at 19:12:26 UTC by Wilbert Pol
(MESS) a2600: Reimplemented the a2600 controllers as vcs controller devices. Switched the a2600 drivers to use slot devices for choosing controllers.  [Wilbert Pol]
[src/mame/video]tia.h
[src/mess]mess.mak
[src/mess/drivers]a2600.c
[src/mess/machine]vcs_joybooster.c* vcs_joybooster.h* vcs_keypad.c* vcs_keypad.h* vcs_wheel.c* vcs_wheel.h* vcsctrl.c vcsctrl.h

trunk/src/mame/video/tia.h
r18679r18680
88
99#define TIA_PALETTE_LENGTH            128 + 128 * 128
1010#define TIA_INPUT_PORT_ALWAYS_ON      0
11#define TIA_INPUT_PORT_ALWAYS_OFF      0xffff
11#define TIA_INPUT_PORT_ALWAYS_OFF      0xff
1212#define TIA_MAX_SCREEN_HEIGHT         342
1313
1414#define HMOVE_INACTIVE      -200
trunk/src/mess/drivers/a2600.c
r18679r18680
5151   a2600_state(const machine_config &mconfig, device_type type, const char *tag)
5252      : driver_device(mconfig, type, tag)
5353      , m_riot_ram(*this, "riot_ram")
54//      , m_joy1(*this, CONTROL1_TAG)
55//      , m_joy2(*this, CONTROL2_TAG)
54      , m_joy1(*this, CONTROL1_TAG)
55      , m_joy2(*this, CONTROL2_TAG)
5656      { }
5757
5858   dpc_t m_dpc;
r18679r18680
6161   UINT8* m_ram_base;
6262   required_shared_ptr<UINT8> m_riot_ram;
6363   UINT8 m_banking_mode;
64   UINT8 m_keypad_left_column;
65   UINT8 m_keypad_right_column;
6664   unsigned m_cart_size;
6765   unsigned m_number_banks;
6866   unsigned m_current_bank;
r18679r18680
132130   DECLARE_READ8_MEMBER(riot_input_port_8_r);
133131
134132protected:
135//  required_device<vcs_control_port_device> m_joy1;
136//  required_device<vcs_control_port_device> m_joy2;
133   required_device<vcs_control_port_device> m_joy1;
134   required_device<vcs_control_port_device> m_joy2;
137135   int next_bank();
138136   void modeF8_switch(UINT16 offset, UINT8 data);
139137   void modeFA_switch(UINT16 offset, UINT8 data);
r18679r18680
164162#define MASTER_CLOCK_PAL   3546894
165163#define CATEGORY_SELECT      16
166164
167/* Some defines for the naming of the controller ports and the controllers */
168#define   STR_LEFT_CONTROLLER      "Left Controller"
169#define STR_RIGHT_CONTROLLER   "Right Controller"
170#define STR_PADDLES            "Paddles"
171#define STR_DRIVING            "Driving"
172#define STR_KEYPAD            "Keypad"
173#define STR_LIGHTGUN         "Lightgun"
174#define STR_BOOSTERGRIP         "Booster Grip"
175#define STR_CX22TRAKBALL      "CX-22 Trak-Ball"
176#define STR_CX80TRAKBALL      "CX-80 Trak-Ball (TB Mode) / AtariST Mouse"
177#define STR_AMIGAMOUSE         "Amiga Mouse"
178#define STR_KIDVID            "KidVid Voice Module"
179
180165enum
181166{
182167   mode2K,
r18679r18680
12941279WRITE8_MEMBER(a2600_state::switch_A_w)
12951280{
12961281   /* Left controller port */
1297   if ( machine().root_device().ioport("CONTROLLERS")->read() / CATEGORY_SELECT == 0x03 )
1298   {
1299      m_keypad_left_column = data / 16;
1300   }
1282   m_joy1->joy_w( data >> 4 );
13011283
13021284   /* Right controller port */
1303   switch( machine().root_device().ioport("CONTROLLERS")->read() % CATEGORY_SELECT )
1304   {
1305   case 0x03:   /* Keypad */
1306      m_keypad_right_column = data & 0x0F;
1307      break;
1308   case 0x0a:   /* KidVid voice module */
1309      machine().device<cassette_image_device>(CASSETTE_TAG)->change_state(( data & 0x02 ) ? (cassette_state)CASSETTE_MOTOR_DISABLED : (cassette_state)(CASSETTE_MOTOR_ENABLED | CASSETTE_PLAY), (cassette_state)CASSETTE_MOTOR_DISABLED );
1310      break;
1311   }
1285   m_joy2->joy_w( data & 0x0f );
1286
1287//   switch( machine().root_device().ioport("CONTROLLERS")->read() % CATEGORY_SELECT )
1288//   {
1289//   case 0x0a:   /* KidVid voice module */
1290//      machine().device<cassette_image_device>(CASSETTE_TAG)->change_state(( data & 0x02 ) ? (cassette_state)CASSETTE_MOTOR_DISABLED : (cassette_state)(CASSETTE_MOTOR_ENABLED | CASSETTE_PLAY), (cassette_state)CASSETTE_MOTOR_DISABLED );
1291//      break;
1292//   }
13121293}
13131294
13141295READ8_MEMBER(a2600_state::switch_A_r)
13151296{
1316   static const UINT8 driving_lookup[4] = { 0x00, 0x02, 0x03, 0x01 };
13171297   UINT8 val = 0;
13181298
13191299   /* Left controller port PINs 1-4 ( 4321 ) */
1320   switch( machine().root_device().ioport("CONTROLLERS")->read() / CATEGORY_SELECT )
1321   {
1322   case 0x00:  /* Joystick */
1323   case 0x05:   /* Joystick w/Boostergrip */
1324      val |= machine().root_device().ioport("SWA_JOY")->read() & 0xF0;
1325//      val |= ( m_joy1->joy_r() & 0x0F ) << 4;
1326      break;
1327   case 0x01:  /* Paddle */
1328      val |= machine().root_device().ioport("SWA_PAD")->read() & 0xF0;
1329      break;
1330   case 0x02:   /* Driving */
1331      val |= 0xC0;
1332      val |= ( driving_lookup[ ( machine().root_device().ioport("WHEEL_L")->read() & 0x18 ) >> 3 ] << 4 );
1333      break;
1334   case 0x06:   /* Trakball CX-22 */
1335   case 0x07:   /* Trakball CX-80 / ST mouse */
1336   case 0x09:   /* Amiga mouse */
1337   default:
1338      val |= 0xF0;
1339      break;
1340   }
1300   val |= ( m_joy1->joy_r() & 0x0F ) << 4;
13411301
13421302   /* Right controller port PINs 1-4 ( 4321 ) */
1343   switch( machine().root_device().ioport("CONTROLLERS")->read() % CATEGORY_SELECT )
1344   {
1345   case 0x00:   /* Joystick */
1346   case 0x05:   /* Joystick w/Boostergrip */
1347      val |= machine().root_device().ioport("SWA_JOY")->read() & 0x0F;
1348      break;
1349   case 0x01:   /* Paddle */
1350      val |= machine().root_device().ioport("SWA_PAD")->read() & 0x0F;
1351      break;
1352   case 0x02:   /* Driving */
1353      val |= 0x0C;
1354      val |= ( driving_lookup[ ( machine().root_device().ioport("WHEEL_R")->read() & 0x18 ) >> 3 ] );
1355      break;
1356   case 0x06:   /* Trakball CX-22 */
1357   case 0x07:   /* Trakball CX-80 / ST mouse */
1358   case 0x09:   /* Amiga mouse */
1359   default:
1360      val |= 0x0F;
1361      break;
1362   }
1303   val |= m_joy2->joy_r() & 0x0F;
13631304
13641305   return val;
13651306}
r18679r18680
14121353
14131354READ16_MEMBER(a2600_state::a2600_read_input_port)
14141355{
1415   int i;
1416
14171356   switch( offset )
14181357   {
14191358   case 0:   /* Left controller port PIN 5 */
1420      switch ( ioport("CONTROLLERS")->read() / CATEGORY_SELECT )
1421      {
1422      case 0x00:   /* Joystick */
1423         return TIA_INPUT_PORT_ALWAYS_OFF;
1424      case 0x01:   /* Paddle */
1425         return ioport("PADDLE1")->read();
1426      case 0x03:   /* Keypad */
1427         for ( i = 0; i < 4; i++ )
1428         {
1429            if ( ! ( ( m_keypad_left_column >> i ) & 0x01 ) )
1430            {
1431               if ( ( ioport("KEYPAD_L")->read() >> 3*i ) & 0x01 )
1432               {
1433                  return TIA_INPUT_PORT_ALWAYS_ON;
1434               }
1435               else
1436               {
1437                  return TIA_INPUT_PORT_ALWAYS_OFF;
1438               }
1439            }
1440         }
1441         return TIA_INPUT_PORT_ALWAYS_ON;
1442      case 0x05:   /* Boostergrip joystick */
1443         return ( ioport("BUTTONS_L")->read() & 0x40 ) ? TIA_INPUT_PORT_ALWAYS_OFF : TIA_INPUT_PORT_ALWAYS_ON;
1444      default:
1445         return TIA_INPUT_PORT_ALWAYS_OFF;
1446      }
1447      break;
1448   case 1:   /* Right controller port PIN 5 */
1449      switch ( ioport("CONTROLLERS")->read() / CATEGORY_SELECT )
1450      {
1451      case 0x00:   /* Joystick */
1452         return TIA_INPUT_PORT_ALWAYS_OFF;
1453      case 0x01:   /* Paddle */
1454         return ioport("PADDLE3")->read();
1455      case 0x03:   /* Keypad */
1456         for ( i = 0; i < 4; i++ )
1457         {
1458            if ( ! ( ( m_keypad_left_column >> i ) & 0x01 ) )
1459            {
1460               if ( ( ioport("KEYPAD_L")->read() >> 3*i ) & 0x02 )
1461               {
1462                  return TIA_INPUT_PORT_ALWAYS_ON;
1463               }
1464               else
1465               {
1466                  return TIA_INPUT_PORT_ALWAYS_OFF;
1467               }
1468            }
1469         }
1470         return TIA_INPUT_PORT_ALWAYS_ON;
1471      case 0x05:   /* Joystick w/Boostergrip */
1472         return ( ioport("BUTTONS_L")->read() & 0x20 ) ? TIA_INPUT_PORT_ALWAYS_OFF : TIA_INPUT_PORT_ALWAYS_ON;
1473      default:
1474         return TIA_INPUT_PORT_ALWAYS_OFF;
1475      }
1476      break;
1477   case 2:   /* Left controller port PIN 9 */
1478      switch ( ioport("CONTROLLERS")->read() % CATEGORY_SELECT )
1479      {
1480      case 0x00:   /* Joystick */
1481         return TIA_INPUT_PORT_ALWAYS_OFF;
1482      case 0x01:   /* Paddle */
1483         return ioport("PADDLE2")->read();
1484      case 0x03:   /* Keypad */
1485         for ( i = 0; i < 4; i++ )
1486         {
1487            if ( ! ( ( m_keypad_right_column >> i ) & 0x01 ) )
1488            {
1489               if ( ( ioport("KEYPAD_R")->read() >> 3*i ) & 0x01 )
1490               {
1491                  return TIA_INPUT_PORT_ALWAYS_ON;
1492               }
1493               else
1494               {
1495                  return TIA_INPUT_PORT_ALWAYS_OFF;
1496               }
1497            }
1498         }
1499         return TIA_INPUT_PORT_ALWAYS_ON;
1500      case 0x05:   /* Joystick w/Boostergrip */
1501         return ( ioport("BUTTONS_R")->read() & 0x40 ) ? TIA_INPUT_PORT_ALWAYS_OFF : TIA_INPUT_PORT_ALWAYS_ON;
1502      default:
1503         return TIA_INPUT_PORT_ALWAYS_OFF;
1504      }
1505      break;
1359      return m_joy1->pot_x_r();
1360
1361   case 1:   /* Left controller port PIN 9 */
1362      return m_joy1->pot_y_r();
1363
1364   case 2:   /* Right controller port PIN 5 */
1365      return m_joy2->pot_x_r();
1366
15061367   case 3:   /* Right controller port PIN 9 */
1507      switch ( ioport("CONTROLLERS")->read() % CATEGORY_SELECT )
1508      {
1509      case 0x00:   /* Joystick */
1510         return TIA_INPUT_PORT_ALWAYS_OFF;
1511      case 0x01:   /* Paddle */
1512         return ioport("PADDLE4")->read();
1513      case 0x03:   /* Keypad */
1514         for ( i = 0; i < 4; i++ )
1515         {
1516            if ( ! ( ( m_keypad_right_column >> i ) & 0x01 ) )
1517            {
1518               if ( ( ioport("KEYPAD_R")->read() >> 3*i ) & 0x02 )
1519               {
1520                  return TIA_INPUT_PORT_ALWAYS_ON;
1521               }
1522               else
1523               {
1524                  return TIA_INPUT_PORT_ALWAYS_OFF;
1525               }
1526            }
1527         }
1528         return TIA_INPUT_PORT_ALWAYS_ON;
1529      case 0x05:   /* Joystick w/Boostergrip */
1530         return ( ioport("BUTTONS_R")->read() & 0x20 ) ? TIA_INPUT_PORT_ALWAYS_OFF : TIA_INPUT_PORT_ALWAYS_ON;
1531      default:
1532         return TIA_INPUT_PORT_ALWAYS_OFF;
1533      }
1534      break;
1368      return m_joy2->pot_y_r();
1369
15351370   case 4:   /* Left controller port PIN 6 */
1536      switch ( ioport("CONTROLLERS")->read() / CATEGORY_SELECT )
1537      {
1538      case 0x00:   /* Joystick */
1539      case 0x05:   /* Joystick w/Boostergrip */
1540         return ioport("BUTTONS_L")->read();
1541      case 0x01:   /* Paddle */
1542         return 0xff;
1543      case 0x02:   /* Driving */
1544         return ioport("BUTTONS_L")->read() << 3;
1545      case 0x03:   /* Keypad */
1546         for ( i = 0; i < 4; i++ )
1547         {
1548            if ( ! ( ( m_keypad_left_column >> i ) & 0x01 ) )
1549            {
1550               if ( ( ioport("KEYPAD_L")->read() >> 3*i ) & 0x04 )
1551               {
1552                  return 0xff;
1553               }
1554               else
1555               {
1556                  return 0x00;
1557               }
1558            }
1559         }
1560         return 0xff;
1561      case 0x06:   /* Trakball CX-22 */
1562         return ioport("BUTTONS_L")->read() << 4;
1563      default:
1564         return 0xff;
1565      }
1566      break;
1371      return ( m_joy1->joy_r() & 0x20 ) ? 0xff : 0x7f;
1372
15671373   case 5:   /* Right controller port PIN 6 */
1568      switch ( ioport("CONTROLLERS")->read() % CATEGORY_SELECT )
1569      {
1570      case 0x00:   /* Joystick */
1571      case 0x05:   /* Joystick w/Boostergrip */
1572         return ioport("BUTTONS_R")->read();
1573      case 0x01:   /* Paddle */
1574         return 0xff;
1575      case 0x02:   /* Driving */
1576         return ioport("BUTTONS_R")->read() << 3;
1577      case 0x03:   /* Keypad */
1578         for ( i = 0; i < 4; i++ )
1579         {
1580            if ( ! ( ( m_keypad_right_column >> i ) & 0x01 ) )
1581            {
1582               if ( ( ioport("KEYPAD_R")->read() >> 3*i ) & 0x04 )
1583               {
1584                  return 0xff;
1585               }
1586               else
1587               {
1588                  return 0x00;
1589               }
1590            }
1591         }
1592         return 0xff;
1593      case 0x06:   /* Trakball CX-22 */
1594         return ioport("BUTTONS_R")->read() << 4;
1595      default:
1596         return 0xff;
1597      }
1374      return ( m_joy2->joy_r() & 0x20 ) ? 0xff : 0x7f;
15981375   }
1599   return TIA_INPUT_PORT_ALWAYS_OFF;
1376   return 0xff;
16001377}
16011378
16021379/* There are a few games that do an LDA ($80-$FF),Y instruction.
r18679r18680
17861563   if (foundkeypad) return (KEYP << 16) + KEYP;
17871564   return (left << 16) + right;
17881565}
1789
1790static void set_category_value( running_machine &machine, const char* cat, const char *cat_selection )
1791{
1792   /* NPW 22-May-2008 - FIXME */
1793#if 0
1794   input_port_entry   *cat_in = NULL;
1795   input_port_entry   *in;
1796
1797   for( in = machine.input_ports; in->type != IPT_END; in++ )
1798   {
1799      if ( in->type == IPT_CATEGORY_NAME && ! mame_stricmp( cat, input_port_name(in) ) )
1800      {
1801         cat_in = in;
1802      }
1803      if ( cat_in && in->type == IPT_CATEGORY_SETTING && ! mame_stricmp( cat_selection, input_port_name(in) ) )
1804      {
1805         cat_in->default_value = in->default_value;
1806         return;
1807      }
1808   }
18091566#endif
1810}
18111567
1812static void set_controller( running_machine &machine, const char *controller, unsigned int selection )
1813{
1814   /* Defaulting to only joystick when joysstick and paddle are set for now... */
1815   if ( selection == JOYS + PADD )
1816      selection = JOYS;
1817
1818   switch( selection )
1819   {
1820   case JOYS:   set_category_value( machine, controller, "Joystick" ); break;
1821   case PADD:   set_category_value( machine, controller, STR_PADDLES ); break;
1822   case KEYP:   set_category_value( machine, controller, STR_KEYPAD ); break;
1823   case LGUN:   set_category_value( machine, controller, STR_LIGHTGUN ); break;
1824   case INDY:   set_category_value( machine, controller, STR_DRIVING ); break;
1825   case BOOS:   set_category_value( machine, controller, STR_BOOSTERGRIP ); break;
1826   case KVID:   set_category_value( machine, controller, STR_KIDVID ); break;
1827   case CMTE:   break;
1828   case MLNK:   break;
1829   case AMSE:   set_category_value( machine, controller, STR_AMIGAMOUSE ); break;
1830   case CX22:   set_category_value( machine, controller, STR_CX22TRAKBALL ); break;
1831   case CX80:   set_category_value( machine, controller, STR_CX80TRAKBALL ); break;
1832   }
1833}
1834#endif
1835
18361568void a2600_state::machine_reset()
18371569{
18381570   address_space& space = machine().device("maincpu")->memory().space(AS_PROGRAM);
r18679r18680
18411573
18421574   m_current_reset_bank_counter++;
18431575
1844#ifdef UNUSED_FUNCTIONS
1845   /* auto-detect special controllers */
1846   unsigned long controltemp;
1847   controltemp = detect_2600controllers(machine());
1848   set_controller( machine(), STR_LEFT_CONTROLLER, controltemp >> 16 );
1849   set_controller( machine(), STR_RIGHT_CONTROLLER, controltemp & 0xFFFF );
1850#endif
1851
18521576   /* auto-detect bank mode */
18531577   if (m_banking_mode == 0xff) if (detect_modeDC(machine())) m_banking_mode = modeDC;
18541578   if (m_banking_mode == 0xff) if (detect_mode3E(machine())) m_banking_mode = mode3E;
r18679r18680
21821906
21831907
21841908static INPUT_PORTS_START( a2600 )
2185
2186   PORT_START("PADDLE1")
2187   PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_SENSITIVITY(40) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_PLAYER(1) PORT_REVERSE PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x10)
2188   PORT_START("PADDLE3")
2189   PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_SENSITIVITY(40) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_PLAYER(3) PORT_REVERSE PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x10)
2190   PORT_START("PADDLE2")
2191   PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_SENSITIVITY(40) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_PLAYER(2) PORT_REVERSE PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x01)
2192   PORT_START("PADDLE4")
2193   PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_SENSITIVITY(40) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_PLAYER(4) PORT_REVERSE PORT_CODE_DEC(KEYCODE_4_PAD) PORT_CODE_INC(KEYCODE_6_PAD) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x01)
2194
2195   PORT_START("BUTTONS_L") /* left port button(s) */
2196//  PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x50)
2197//  PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x50)
2198   PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x50)
2199   PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x20)
2200   PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x00)
2201   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x00)
2202   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x00)
2203
2204   PORT_START("BUTTONS_R") /* right port button(s) */
2205//  PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x05)
2206//  PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x05)
2207   PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x05)
2208   PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x02)
2209   PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x00)
2210   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x00)
2211   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x00)
2212
2213   PORT_START("SWA_JOY") /* SWCHA joystick */
2214   PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x00)
2215   PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x00)
2216   PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x00)
2217   PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x00)
2218   PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x00)
2219   PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x00)
2220   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x00)
2221   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x00)
2222
2223   PORT_START("SWA_PAD") /* SWCHA paddles */
2224   PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
2225   PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
2226   PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(4) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x01)
2227   PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x01)
2228   PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_UNUSED )
2229   PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_UNUSED )
2230   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x10)
2231   PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x10)
2232
22331909   PORT_START("SWB") /* SWCHB */
22341910   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("Reset Game") PORT_CODE(KEYCODE_2)
22351911   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START ) PORT_NAME("Select Game")
r18679r18680
22451921   PORT_DIPNAME( 0x80, 0x00, "Right Diff. Switch" ) PORT_CODE(KEYCODE_4) PORT_TOGGLE
22461922   PORT_DIPSETTING(    0x80, "A" )
22471923   PORT_DIPSETTING(    0x00, "B" )
2248
2249   PORT_START("CONTROLLERS")
2250   PORT_CONFNAME( 0xf0, 0x00, STR_LEFT_CONTROLLER )
2251   PORT_CONFSETTING(    0x00, DEF_STR( Joystick ) )
2252   PORT_CONFSETTING(    0x10, STR_PADDLES )
2253   PORT_CONFSETTING(    0x20, STR_DRIVING )
2254   PORT_CONFSETTING(    0x30, STR_KEYPAD )
2255   //PORT_CONFSETTING(    0x40, STR_LIGHTGUN )
2256   PORT_CONFSETTING(    0x50, STR_BOOSTERGRIP )
2257   //PORT_CONFSETTING(    0x60, STR_CX22TRAKBALL )
2258   //PORT_CONFSETTING(    0x70, STR_CX80TRAKBALL )
2259   //PORT_CONFSETTING(    0x80, "CX-80 Trak-Ball (JS Mode)" )
2260   //PORT_CONFSETTING(    0x90, STR_AMIGAMOUSE )
2261   PORT_CONFNAME( 0x0f, 0x00, STR_RIGHT_CONTROLLER )
2262   PORT_CONFSETTING(    0x00, DEF_STR( Joystick ) )
2263   PORT_CONFSETTING(    0x01, STR_PADDLES )
2264   PORT_CONFSETTING(    0x02, STR_DRIVING )
2265   PORT_CONFSETTING(    0x03, STR_KEYPAD )
2266   //PORT_CONFSETTING(    0x04, STR_LIGHTGUN )
2267   PORT_CONFSETTING(    0x05, STR_BOOSTERGRIP )
2268   //PORT_CONFSETTING(    0x06, STR_CX22TRAKBALL )
2269   //PORT_CONFSETTING(    0x07, STR_CX80TRAKBALL )
2270   //PORT_CONFSETTING(    0x08, "CX-80 Trak-Ball (JS Mode)" )
2271   //PORT_CONFSETTING(    0x09, STR_AMIGAMOUSE )
2272   PORT_CONFSETTING(    0x0a, STR_KIDVID )
2273   //PORT_CONFSETTING(    0x0b, "Save Key" )
2274
2275   PORT_START("KEYPAD_L")   /* left keypad */
2276   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 1") PORT_CODE(KEYCODE_7_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2277   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 2") PORT_CODE(KEYCODE_8_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2278   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 3") PORT_CODE(KEYCODE_9_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2279   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 4") PORT_CODE(KEYCODE_4_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2280   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 5") PORT_CODE(KEYCODE_5_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2281   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 6") PORT_CODE(KEYCODE_6_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2282   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 7") PORT_CODE(KEYCODE_1_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2283   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 8") PORT_CODE(KEYCODE_2_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2284   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 9") PORT_CODE(KEYCODE_3_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2285   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left *") PORT_CODE(KEYCODE_0_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2286   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left 0") PORT_CODE(KEYCODE_DEL_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2287   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("left #") PORT_CODE(KEYCODE_ENTER_PAD) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x30)
2288
2289   PORT_START("KEYPAD_R")  /* right keypad */
2290   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 1") PORT_CODE(KEYCODE_5) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2291   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 2") PORT_CODE(KEYCODE_6) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2292   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 3") PORT_CODE(KEYCODE_7) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2293   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 4") PORT_CODE(KEYCODE_R) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2294   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 5") PORT_CODE(KEYCODE_T) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2295   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 6") PORT_CODE(KEYCODE_Y) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2296   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 7") PORT_CODE(KEYCODE_F) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2297   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 8") PORT_CODE(KEYCODE_G) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2298   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 9") PORT_CODE(KEYCODE_H) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2299   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right *") PORT_CODE(KEYCODE_V) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2300   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right 0") PORT_CODE(KEYCODE_B) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2301   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("right #") PORT_CODE(KEYCODE_N) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x03)
2302
2303   PORT_START("WHEEL_L")   /* left driving controller */
2304   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x20)
2305
2306   PORT_START("WHEEL_R")   /* right driving controller */
2307   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x02)
2308
2309   PORT_START("GUNX_L")   /* left light gun X */
2310//  PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x40)
2311
2312   PORT_START("GUNY_L")   /* left light gun Y */
2313//  PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x40)
2314
2315   PORT_START("GUNX_R")   /* right light gun X */
2316//  PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x04)
2317
2318   PORT_START("GUNY_R")   /* right light gun Y */
2319//  PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x04)
2320
2321   PORT_START("TRAKX_L")   /* left trak ball X */
2322   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x50)
2323
2324   PORT_START("TRAKY_L")   /* left trak ball Y */
2325   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(1) PORT_CONDITION("CONTROLLERS", 0xf0, EQUALS, 0x50)
2326
2327   PORT_START("TRAKX_R")   /* right trak ball X */
2328   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x05)
2329
2330   PORT_START("TRAKY_R")   /* right trak ball Y */
2331   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(2) PORT_CONDITION("CONTROLLERS", 0x0f, EQUALS, 0x05)
2332
23331924INPUT_PORTS_END
23341925
23351926
r18679r18680
23821973   /* devices */
23831974   MCFG_RIOT6532_ADD("riot", MASTER_CLOCK_NTSC / 3, r6532_interface)
23841975
2385//  MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL)
2386//  MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL)
1976   MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy", NULL)
1977   MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL)
23871978
23881979   MCFG_FRAGMENT_ADD(a2600_cartslot)
23891980   MCFG_SOFTWARE_LIST_FILTER("cart_list", "NTSC")
r18679r18680
24182009   /* devices */
24192010   MCFG_RIOT6532_ADD("riot", MASTER_CLOCK_PAL / 3, r6532_interface)
24202011
2421//  MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, NULL, NULL)
2422//  MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL)
2012   MCFG_VCS_CONTROL_PORT_ADD(CONTROL1_TAG, vcs_control_port_devices, "joy", NULL)
2013   MCFG_VCS_CONTROL_PORT_ADD(CONTROL2_TAG, vcs_control_port_devices, NULL, NULL)
24232014
24242015   MCFG_FRAGMENT_ADD(a2600_cartslot)
24252016   MCFG_SOFTWARE_LIST_FILTER("cart_list", "PAL")
trunk/src/mess/mess.mak
r18679r18680
560560   $(MESS_MACHINE)/vcs_joy.o   \
561561   $(MESS_MACHINE)/vcs_lightpen.o   \
562562   $(MESS_MACHINE)/vcs_paddles.o   \
563   $(MESS_MACHINE)/vcs_joybooster.o   \
564   $(MESS_MACHINE)/vcs_wheel.o   \
565   $(MESS_MACHINE)/vcs_keypad.o   \
563566
564567
565568
trunk/src/mess/machine/vcs_keypad.c
r0r18680
1/**********************************************************************
2
3    Atari Video Computer System keypad emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "vcs_keypad.h"
11
12
13
14//**************************************************************************
15//  DEVICE DEFINITIONS
16//**************************************************************************
17
18const device_type VCS_KEYPAD = &device_creator<vcs_keypad_device>;
19
20
21static INPUT_PORTS_START( vcs_keypad )
22   PORT_START("KEYPAD")
23   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 1") PORT_CODE(KEYCODE_7_PAD)
24   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 2") PORT_CODE(KEYCODE_8_PAD)
25   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 3") PORT_CODE(KEYCODE_9_PAD)
26   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 4") PORT_CODE(KEYCODE_4_PAD)
27   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 5") PORT_CODE(KEYCODE_5_PAD)
28   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 6") PORT_CODE(KEYCODE_6_PAD)
29   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 7") PORT_CODE(KEYCODE_1_PAD)
30   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 8") PORT_CODE(KEYCODE_2_PAD)
31   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 9") PORT_CODE(KEYCODE_3_PAD)
32   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad *") PORT_CODE(KEYCODE_0_PAD)
33   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad 0") PORT_CODE(KEYCODE_DEL_PAD)
34   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("keypad #") PORT_CODE(KEYCODE_ENTER_PAD)
35INPUT_PORTS_END
36
37
38//-------------------------------------------------
39//  input_ports - device-specific input ports
40//-------------------------------------------------
41
42ioport_constructor vcs_keypad_device::device_input_ports() const
43{
44   return INPUT_PORTS_NAME( vcs_keypad );
45}
46
47
48
49//**************************************************************************
50//  LIVE DEVICE
51//**************************************************************************
52
53//-------------------------------------------------
54//  vcs_keypad_device - constructor
55//-------------------------------------------------
56
57vcs_keypad_device::vcs_keypad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
58   device_t(mconfig, VCS_KEYPAD, "Keypad", tag, owner, clock),
59   device_vcs_control_port_interface(mconfig, *this)
60{
61}
62
63
64//-------------------------------------------------
65//  device_start - device-specific startup
66//-------------------------------------------------
67
68void vcs_keypad_device::device_start()
69{
70   m_column = 0;
71   save_item(NAME(m_column));
72}
73
74
75//-------------------------------------------------
76//  vcs_joy_w - joystick write
77//-------------------------------------------------
78
79UINT8 vcs_keypad_device::vcs_joy_r()
80{
81   for ( int i = 0; i < 4; i++ )
82   {
83      if ( ! ( ( m_column >> i ) & 0x01 ) )
84      {
85         if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x04 )
86         {
87            return 0xff;
88         }
89         else
90         {
91            return 0;
92         }
93      }
94   }
95   return 0xff;
96}
97
98void vcs_keypad_device::vcs_joy_w( UINT8 data )
99{
100   m_column = data & 0x0F;
101}
102
103UINT8 vcs_keypad_device::vcs_pot_x_r()
104{
105   for ( int i = 0; i < 4; i++ )
106   {
107      if ( ! ( ( m_column >> i ) & 0x01 ) )
108      {
109         if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x01 )
110         {
111            return 0;
112         }
113         else
114         {
115            return 0xff;
116         }
117      }
118   }
119   return 0;
120}
121
122UINT8 vcs_keypad_device::vcs_pot_y_r()
123{
124   for ( int i = 0; i < 4; i++ )
125   {
126      if ( ! ( ( m_column >> i ) & 0x01 ) )
127      {
128         if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x02 )
129         {
130            return 0;
131         }
132         else
133         {
134            return 0xff;
135         }
136      }
137   }
138   return 0;
139}
140
trunk/src/mess/machine/vcs_keypad.h
r0r18680
1/**********************************************************************
2
3    Atari Video Computer System Keypad emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __VCS_KEYPAD__
13#define __VCS_KEYPAD__
14
15
16#include "emu.h"
17#include "machine/vcsctrl.h"
18
19
20
21//**************************************************************************
22//  TYPE DEFINITIONS
23//**************************************************************************
24
25// ======================> vcs_keypad_device
26
27class vcs_keypad_device : public device_t,
28                     public device_vcs_control_port_interface
29{
30public:
31   // construction/destruction
32   vcs_keypad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
33
34   // optional information overrides
35   virtual ioport_constructor device_input_ports() const;
36
37protected:
38   // device-level overrides
39   virtual void device_config_complete() { m_shortname = "vcs_keypad"; }
40   virtual void device_start();
41
42   // device_vcs_control_port_interface overrides
43   virtual UINT8 vcs_joy_r();
44   virtual void vcs_joy_w( UINT8 data );
45   virtual UINT8 vcs_pot_x_r();
46   virtual UINT8 vcs_pot_y_r();
47
48   UINT8   m_column;
49};
50
51
52// device type definition
53extern const device_type VCS_KEYPAD;
54
55
56#endif
trunk/src/mess/machine/vcs_wheel.c
r0r18680
1/**********************************************************************
2
3    Atari Video Computer System Driving Wheel emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "vcs_wheel.h"
11
12
13
14//**************************************************************************
15//  DEVICE DEFINITIONS
16//**************************************************************************
17
18const device_type VCS_WHEEL = &device_creator<vcs_wheel_device>;
19
20
21static INPUT_PORTS_START( vcs_wheel )
22   PORT_START("JOY")
23   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )                     // Pin 6
24   PORT_BIT( 0xdc, IP_ACTIVE_LOW, IPT_UNUSED )
25
26   PORT_START("WHEEL")
27   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(40) PORT_KEYDELTA(5)
28INPUT_PORTS_END
29
30
31//-------------------------------------------------
32//  input_ports - device-specific input ports
33//-------------------------------------------------
34
35ioport_constructor vcs_wheel_device::device_input_ports() const
36{
37   return INPUT_PORTS_NAME( vcs_wheel );
38}
39
40
41
42//**************************************************************************
43//  LIVE DEVICE
44//**************************************************************************
45
46//-------------------------------------------------
47//  vcs_wheel_device - constructor
48//-------------------------------------------------
49
50vcs_wheel_device::vcs_wheel_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
51   device_t(mconfig, VCS_WHEEL, "Driving Wheel", tag, owner, clock),
52   device_vcs_control_port_interface(mconfig, *this)
53{
54}
55
56
57//-------------------------------------------------
58//  device_start - device-specific startup
59//-------------------------------------------------
60
61void vcs_wheel_device::device_start()
62{
63}
64
65
66//-------------------------------------------------
67//  vcs_joy_r - joystick read
68//-------------------------------------------------
69
70UINT8 vcs_wheel_device::vcs_joy_r()
71{
72   static const UINT8 driving_lookup[4] = { 0x00, 0x02, 0x03, 0x01 };
73
74   return ioport("JOY")->read() | driving_lookup[ ( ioport("WHEEL")->read() & 0x18 ) >> 3 ];
75}
trunk/src/mess/machine/vcs_wheel.h
r0r18680
1/**********************************************************************
2
3    Atari Video Computer System Driving Wheel emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __VCS_WHEEL__
13#define __VCS_WHEEL__
14
15
16#include "emu.h"
17#include "machine/vcsctrl.h"
18
19
20
21//**************************************************************************
22//  TYPE DEFINITIONS
23//**************************************************************************
24
25// ======================> vcs_wheel_device
26
27class vcs_wheel_device : public device_t,
28                     public device_vcs_control_port_interface
29{
30public:
31   // construction/destruction
32   vcs_wheel_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
33
34   // optional information overrides
35   virtual ioport_constructor device_input_ports() const;
36
37protected:
38   // device-level overrides
39   virtual void device_config_complete() { m_shortname = "vcs_wheel"; }
40   virtual void device_start();
41
42   // device_vcs_control_port_interface overrides
43   virtual UINT8 vcs_joy_r();
44};
45
46
47// device type definition
48extern const device_type VCS_WHEEL;
49
50
51#endif
trunk/src/mess/machine/vcs_joybooster.c
r0r18680
1/**********************************************************************
2
3    Atari Video Computer System digital joystick emulation with
4    boostergrip adapter
5
6    Copyright MESS Team.
7    Visit http://mamedev.org for licensing and usage restrictions.
8
9**********************************************************************/
10
11#include "vcs_joybooster.h"
12
13
14
15//**************************************************************************
16//  DEVICE DEFINITIONS
17//**************************************************************************
18
19const device_type VCS_JOYSTICK_BOOSTER = &device_creator<vcs_joystick_booster_device>;
20
21
22static INPUT_PORTS_START( vcs_joystick_booster )
23   PORT_START("JOY")
24   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY       // Pin 1
25   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY     // Pin 2
26   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY     // Pin 3
27   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY    // Pin 4
28   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 )                     // Pin 6
29   PORT_BIT( 0xd0, IP_ACTIVE_LOW, IPT_UNUSED )
30
31   // Pin 5
32   PORT_START("POTX")
33   PORT_BIT(0xff, IP_ACTIVE_LOW, IPT_BUTTON2 )
34
35   // Pin 9
36   PORT_START("POTY")
37   PORT_BIT(0xff, IP_ACTIVE_LOW, IPT_BUTTON3 )
38INPUT_PORTS_END
39
40
41//-------------------------------------------------
42//  input_ports - device-specific input ports
43//-------------------------------------------------
44
45ioport_constructor vcs_joystick_booster_device::device_input_ports() const
46{
47   return INPUT_PORTS_NAME( vcs_joystick_booster );
48}
49
50
51
52//**************************************************************************
53//  LIVE DEVICE
54//**************************************************************************
55
56//-------------------------------------------------
57//  vcs_joystick_booster_device - constructor
58//-------------------------------------------------
59
60vcs_joystick_booster_device::vcs_joystick_booster_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
61   device_t(mconfig, VCS_JOYSTICK_BOOSTER, "Digital joystick with Boostergrip", tag, owner, clock),
62   device_vcs_control_port_interface(mconfig, *this)
63{
64}
65
66
67//-------------------------------------------------
68//  device_start - device-specific startup
69//-------------------------------------------------
70
71void vcs_joystick_booster_device::device_start()
72{
73}
74
75
76//-------------------------------------------------
77//  vcs_joy_r - joystick read
78//-------------------------------------------------
79
80UINT8 vcs_joystick_booster_device::vcs_joy_r()
81{
82   return ioport("JOY")->read();
83}
84
85UINT8 vcs_joystick_booster_device::vcs_pot_x_r()
86{
87printf("booster return: %02x\n", ioport("POTX")->read() );
88   return ioport("POTX")->read();
89}
90
91UINT8 vcs_joystick_booster_device::vcs_pot_y_r()
92{
93   return ioport("POTY")->read();
94}
95
trunk/src/mess/machine/vcs_joybooster.h
r0r18680
1/**********************************************************************
2
3    Atari Video Computer System digital joystick emulation with
4    boostergrip adapter
5
6    Copyright MESS Team.
7    Visit http://mamedev.org for licensing and usage restrictions.
8
9**********************************************************************/
10
11#pragma once
12
13#ifndef __VCS_JOYSTICKBOOSTER__
14#define __VCS_JOYSTICKBOOSTER__
15
16
17#include "emu.h"
18#include "machine/vcsctrl.h"
19
20
21
22//**************************************************************************
23//  TYPE DEFINITIONS
24//**************************************************************************
25
26// ======================> vcs_joystick_booster_device
27
28class vcs_joystick_booster_device : public device_t,
29                     public device_vcs_control_port_interface
30{
31public:
32   // construction/destruction
33   vcs_joystick_booster_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
34
35   // optional information overrides
36   virtual ioport_constructor device_input_ports() const;
37
38protected:
39   // device-level overrides
40   virtual void device_config_complete() { m_shortname = "vcs_joystick_booster"; }
41   virtual void device_start();
42
43   // device_vcs_control_port_interface overrides
44   virtual UINT8 vcs_joy_r();
45   virtual UINT8 vcs_pot_x_r();
46   virtual UINT8 vcs_pot_y_r();
47};
48
49
50// device type definition
51extern const device_type VCS_JOYSTICK_BOOSTER;
52
53
54#endif
trunk/src/mess/machine/vcsctrl.c
r18679r18680
7575void vcs_control_port_device::device_start()
7676{
7777   m_device = dynamic_cast<device_vcs_control_port_interface *>(get_card_device());
78printf("m_device set to %p\n", m_device);
7879}
7980
8081
r18679r18680
8485READ8_MEMBER( vcs_control_port_device::pot_x_r ) { return pot_x_r(); }
8586UINT8 vcs_control_port_device::pot_y_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_pot_y_r(); return data; }
8687READ8_MEMBER( vcs_control_port_device::pot_y_r ) { return pot_y_r(); }
88void vcs_control_port_device::joy_w( UINT8 data ) { if ( m_device != NULL ) m_device->vcs_joy_w( data ); }
89WRITE8_MEMBER( vcs_control_port_device::joy_w ) { joy_w(data); }
8790
8891
8992//-------------------------------------------------
r18679r18680
9497   SLOT_INTERFACE("joy", VCS_JOYSTICK)
9598   SLOT_INTERFACE("pad", VCS_PADDLES)
9699   SLOT_INTERFACE("lp", VCS_LIGHTPEN)
100   SLOT_INTERFACE("joybstr", VCS_JOYSTICK_BOOSTER)
101   SLOT_INTERFACE("wheel", VCS_WHEEL)
102   SLOT_INTERFACE("keypad", VCS_KEYPAD)
97103SLOT_INTERFACE_END
trunk/src/mess/machine/vcsctrl.h
r18679r18680
5353   UINT8 pot_y_r();
5454   DECLARE_READ8_MEMBER( pot_y_r );
5555
56   void joy_w( UINT8 data );
57   DECLARE_WRITE8_MEMBER( joy_w );
58
5659protected:
5760   // device-level overrides
5861   virtual void device_start();
r18679r18680
7477   virtual UINT8 vcs_joy_r() { return 0xff; };
7578   virtual UINT8 vcs_pot_x_r() { return 0xff; };
7679   virtual UINT8 vcs_pot_y_r() { return 0xff; };
80   virtual void vcs_joy_w(UINT8 data) { };
7781
7882protected:
7983   vcs_control_port_device *m_port;
r18679r18680
8892#include "machine/vcs_joy.h"
8993#include "machine/vcs_lightpen.h"
9094#include "machine/vcs_paddles.h"
95#include "machine/vcs_joybooster.h"
96#include "machine/vcs_wheel.h"
97#include "machine/vcs_keypad.h"
9198
9299SLOT_INTERFACE_EXTERN( vcs_control_port_devices );
93100

Previous 199869 Revisions Next


© 1997-2024 The MAME Team