src/mess/drivers/a2600.c
| r897 | r898 | |
| 20 | 20 | #define MASTER_CLOCK_PAL 3546894 |
| 21 | 21 | #define CATEGORY_SELECT 16 |
| 22 | 22 | |
| 23 | /* Some defines for the naming of the controller ports and the controllers */ |
| 24 | #define STR_LEFT_CONTROLLER "Left Controller" |
| 25 | #define STR_RIGHT_CONTROLLER "Right Controller" |
| 26 | #define STR_PADDLES "Paddles" |
| 27 | #define STR_DRIVING "Driving" |
| 28 | #define STR_KEYPAD "Keypad" |
| 29 | #define STR_LIGHTGUN "Lightgun" |
| 30 | #define STR_BOOSTERGRIP "Booster Grip" |
| 31 | #define STR_CX22TRAKBALL "CX-22 Trak-Ball" |
| 32 | #define STR_CX80TRAKBALL "CX-80 Trak-Ball (TB Mode) / AtariST Mouse" |
| 33 | #define STR_AMIGAMOUSE "Amiga Mouse" |
| 34 | #define STR_KIDVID "KidVid Voice Module" |
| 35 | |
| 23 | 36 | enum |
| 24 | 37 | { |
| 25 | 38 | mode2K, |
| r897 | r898 | |
| 1070 | 1083 | static const UINT8 driving_lookup[4] = { 0x00, 0x02, 0x03, 0x01 }; |
| 1071 | 1084 | UINT8 val = 0; |
| 1072 | 1085 | |
| 1073 | | /* Left controller port */ |
| 1086 | /* Left controller port PINs 1-4 ( 4321 ) */ |
| 1074 | 1087 | switch( readinputport(9) / CATEGORY_SELECT ) { |
| 1075 | 1088 | case 0x00: /* Joystick */ |
| 1076 | 1089 | case 0x05: /* Joystick w/Boostergrip */ |
| r897 | r898 | |
| 1083 | 1096 | val |= 0xC0; |
| 1084 | 1097 | val |= ( driving_lookup[ ( readinputport(12) & 0x18 ) >> 3 ] << 4 ); |
| 1085 | 1098 | break; |
| 1099 | case 0x06: /* Trakball CX-22 */ |
| 1100 | case 0x07: /* Trakball CX-80 / ST mouse */ |
| 1101 | case 0x09: /* Amiga mouse */ |
| 1086 | 1102 | default: |
| 1087 | 1103 | val |= 0xF0; |
| 1088 | 1104 | break; |
| 1089 | 1105 | } |
| 1090 | 1106 | |
| 1091 | | /* Right controller port */ |
| 1107 | /* Right controller port PINs 1-4 ( 4321 ) */ |
| 1092 | 1108 | switch( readinputport(9) % CATEGORY_SELECT ) { |
| 1093 | 1109 | case 0x00: /* Joystick */ |
| 1094 | 1110 | case 0x05: /* Joystick w/Boostergrip */ |
| r897 | r898 | |
| 1101 | 1117 | val |= 0x0C; |
| 1102 | 1118 | val |= ( driving_lookup[ ( readinputport(13) & 0x18 ) >> 3 ] ); |
| 1103 | 1119 | break; |
| 1120 | case 0x06: /* Trakball CX-22 */ |
| 1121 | case 0x07: /* Trakball CX-80 / ST mouse */ |
| 1122 | case 0x09: /* Amiga mouse */ |
| 1104 | 1123 | default: |
| 1105 | 1124 | val |= 0x0F; |
| 1106 | 1125 | break; |
| r897 | r898 | |
| 1152 | 1171 | int i; |
| 1153 | 1172 | |
| 1154 | 1173 | switch( offset ) { |
| 1155 | | case 0: |
| 1174 | case 0: /* Left controller port PIN 5 */ |
| 1156 | 1175 | switch ( readinputport(9) / CATEGORY_SELECT ) { |
| 1157 | 1176 | case 0x00: /* Joystick */ |
| 1158 | 1177 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| r897 | r898 | |
| 1175 | 1194 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| 1176 | 1195 | } |
| 1177 | 1196 | break; |
| 1178 | | case 1: |
| 1197 | case 1: /* Right controller port PIN 5 */ |
| 1179 | 1198 | switch ( readinputport(9) / CATEGORY_SELECT ) { |
| 1180 | 1199 | case 0x00: /* Joystick */ |
| 1181 | 1200 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| r897 | r898 | |
| 1198 | 1217 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| 1199 | 1218 | } |
| 1200 | 1219 | break; |
| 1201 | | case 2: |
| 1220 | case 2: /* Left controller port PIN 9 */ |
| 1202 | 1221 | switch ( readinputport(9) % CATEGORY_SELECT ) { |
| 1203 | 1222 | case 0x00: /* Joystick */ |
| 1204 | 1223 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| r897 | r898 | |
| 1221 | 1240 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| 1222 | 1241 | } |
| 1223 | 1242 | break; |
| 1224 | | case 3: |
| 1243 | case 3: /* Right controller port PIN 9 */ |
| 1225 | 1244 | switch ( readinputport(9) % CATEGORY_SELECT ) { |
| 1226 | 1245 | case 0x00: /* Joystick */ |
| 1227 | 1246 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| r897 | r898 | |
| 1244 | 1263 | return TIA_INPUT_PORT_ALWAYS_OFF; |
| 1245 | 1264 | } |
| 1246 | 1265 | break; |
| 1247 | | case 4: |
| 1266 | case 4: /* Left controller port PIN 6 */ |
| 1248 | 1267 | switch ( readinputport(9) / CATEGORY_SELECT ) { |
| 1249 | 1268 | case 0x00: /* Joystick */ |
| 1250 | 1269 | case 0x05: /* Joystick w/Boostergrip */ |
| r897 | r898 | |
| 1264 | 1283 | } |
| 1265 | 1284 | } |
| 1266 | 1285 | return 0xff; |
| 1286 | case 0x06: /* Trakball CX-22 */ |
| 1287 | return readinputport(4) << 4; |
| 1267 | 1288 | default: |
| 1268 | 1289 | return 0xff; |
| 1269 | 1290 | } |
| 1270 | 1291 | break; |
| 1271 | | case 5: |
| 1292 | case 5: /* Right controller port PIN 6 */ |
| 1272 | 1293 | switch ( readinputport(9) % CATEGORY_SELECT ) { |
| 1273 | 1294 | case 0x00: /* Joystick */ |
| 1274 | 1295 | case 0x05: /* Joystick w/Boostergrip */ |
| r897 | r898 | |
| 1288 | 1309 | } |
| 1289 | 1310 | } |
| 1290 | 1311 | return 0xff; |
| 1312 | case 0x06: /* Trakball CX-22 */ |
| 1313 | return readinputport(5) << 4; |
| 1291 | 1314 | default: |
| 1292 | 1315 | return 0xff; |
| 1293 | 1316 | } |
| r897 | r898 | |
| 1398 | 1421 | current_reset_bank_counter = 0xFF; |
| 1399 | 1422 | } |
| 1400 | 1423 | |
| 1424 | static void set_category_value( const char* cat, const char *cat_selection ) { |
| 1425 | input_port_entry *cat_in = NULL; |
| 1426 | input_port_entry *in; |
| 1427 | |
| 1428 | for( in = Machine->input_ports; in->type != IPT_END; in++ ) { |
| 1429 | if ( in->type == IPT_CATEGORY_NAME && ! mame_stricmp( cat, input_port_name(in) ) ) { |
| 1430 | cat_in = in; |
| 1431 | } |
| 1432 | if ( cat_in && in->type == IPT_CATEGORY_SETTING && ! mame_stricmp( cat_selection, input_port_name(in) ) ) { |
| 1433 | cat_in->default_value = in->default_value; |
| 1434 | return; |
| 1435 | } |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | static void set_controller( const char *controller, unsigned int selection ) { |
| 1440 | /* Defaulting to only joystick when joysstick and paddle are set for now... */ |
| 1441 | if ( selection == JOYS + PADD ) |
| 1442 | selection = JOYS; |
| 1443 | |
| 1444 | switch( selection ) { |
| 1445 | case JOYS: set_category_value( controller, "Joystick" ); break; |
| 1446 | case PADD: set_category_value( controller, STR_PADDLES ); break; |
| 1447 | case KEYP: set_category_value( controller, STR_KEYPAD ); break; |
| 1448 | case LGUN: set_category_value( controller, STR_LIGHTGUN ); break; |
| 1449 | case INDY: set_category_value( controller, STR_DRIVING ); break; |
| 1450 | case BOOS: set_category_value( controller, STR_BOOSTERGRIP ); break; |
| 1451 | case KVID: set_category_value( controller, STR_KIDVID ); break; |
| 1452 | case CMTE: break; |
| 1453 | case MLNK: break; |
| 1454 | case AMSE: set_category_value( controller, STR_AMIGAMOUSE ); break; |
| 1455 | case CX22: set_category_value( controller, STR_CX22TRAKBALL ); break; |
| 1456 | case CX80: set_category_value( controller, STR_CX80TRAKBALL ); break; |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1401 | 1460 | static MACHINE_RESET( a2600 ) |
| 1402 | 1461 | { |
| 1403 | 1462 | |
| 1404 | 1463 | int chip = 0xFF; |
| 1405 | 1464 | unsigned long controltemp; |
| 1406 | | unsigned int controlleft,controlright; |
| 1407 | 1465 | unsigned char snowwhite[] = { 0x10, 0xd0, 0xff, 0xff }; // Snow White Proto |
| 1408 | 1466 | |
| 1409 | 1467 | current_reset_bank_counter++; |
| 1410 | 1468 | |
| 1411 | 1469 | /* auto-detect special controllers */ |
| 1412 | | |
| 1413 | 1470 | controltemp = detect_2600controllers(); |
| 1414 | | controlleft = controltemp >> 16; |
| 1415 | | controlright = controltemp & 0xffff; |
| 1416 | | // todo setup all the PORT_ stuff here |
| 1471 | set_controller( STR_LEFT_CONTROLLER, controltemp >> 16 ); |
| 1472 | set_controller( STR_RIGHT_CONTROLLER, controltemp & 0xFFFF ); |
| 1417 | 1473 | |
| 1418 | 1474 | /* auto-detect bank mode */ |
| 1419 | 1475 | |
| r897 | r898 | |
| 1731 | 1787 | PORT_START /* [3] */ |
| 1732 | 1788 | PORT_BIT( 0xff, 0x80, IPT_PADDLE) PORT_SENSITIVITY(40) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_MINMAX(0,255) PORT_CATEGORY(21) PORT_PLAYER(4) PORT_REVERSE PORT_CODE_DEC(KEYCODE_4_PAD) PORT_CODE_INC(KEYCODE_6_PAD) |
| 1733 | 1789 | |
| 1734 | | PORT_START /* [4] */ |
| 1790 | PORT_START /* [4] left port button(s) */ |
| 1791 | // PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_CATEGORY(15) PORT_PLAYER(1) |
| 1792 | // PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CATEGORY(15) PORT_PLAYER(1) |
| 1793 | PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CATEGORY(15) PORT_PLAYER(1) |
| 1735 | 1794 | PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CATEGORY(12) PORT_PLAYER(1) |
| 1736 | 1795 | PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 1737 | 1796 | PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 1738 | 1797 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 1739 | 1798 | |
| 1740 | | PORT_START /* [5] */ |
| 1799 | PORT_START /* [5] right port button(s) */ |
| 1800 | // PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_CATEGORY(25) PORT_PLAYER(2) |
| 1801 | // PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CATEGORY(25) PORT_PLAYER(2) |
| 1802 | PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CATEGORY(25) PORT_PLAYER(2) |
| 1741 | 1803 | PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_CATEGORY(22) PORT_PLAYER(2) |
| 1742 | 1804 | PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_BUTTON3) PORT_CATEGORY(20) PORT_PLAYER(2) |
| 1743 | 1805 | PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_CATEGORY(20) PORT_PLAYER(2) |
| r897 | r898 | |
| 1780 | 1842 | PORT_DIPSETTING( 0x00, "B" ) |
| 1781 | 1843 | |
| 1782 | 1844 | PORT_START /* [9] */ |
| 1783 | | PORT_CATEGORY_CLASS( 0xf0, 0x00, "Left Controller" ) |
| 1845 | PORT_CATEGORY_CLASS( 0xf0, 0x00, STR_LEFT_CONTROLLER ) |
| 1784 | 1846 | PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 10 ) |
| 1785 | | PORT_CATEGORY_ITEM( 0x10, "Paddles", 11 ) |
| 1786 | | PORT_CATEGORY_ITEM( 0x20, "Driving", 12 ) |
| 1787 | | PORT_CATEGORY_ITEM( 0x30, "Keypad", 13 ) |
| 1788 | | //PORT_CATEGORY_ITEM( 0x40, "Lightgun", 14 ) |
| 1789 | | PORT_CATEGORY_ITEM( 0x50, "Booster Grip", 10 ) |
| 1790 | | //PORT_CATEGORY_ITEM( 0x60, "CX-22 Trak-Ball", 15 ) |
| 1791 | | //PORT_CATEGORY_ITEM( 0x70, "CX-80 Trak-Ball (TB Mode) / AtariST Mouse", 16 ) |
| 1847 | PORT_CATEGORY_ITEM( 0x10, STR_PADDLES, 11 ) |
| 1848 | PORT_CATEGORY_ITEM( 0x20, STR_DRIVING, 12 ) |
| 1849 | PORT_CATEGORY_ITEM( 0x30, STR_KEYPAD, 13 ) |
| 1850 | //PORT_CATEGORY_ITEM( 0x40, STR_LIGHTGUN, 14 ) |
| 1851 | PORT_CATEGORY_ITEM( 0x50, STR_BOOSTERGRIP, 10 ) |
| 1852 | //PORT_CATEGORY_ITEM( 0x60, STR_CX22TRAKBALL, 15 ) |
| 1853 | //PORT_CATEGORY_ITEM( 0x70, STR_CX80TRAKBALL, 15 ) |
| 1792 | 1854 | //PORT_CATEGORY_ITEM( 0x80, "CX-80 Trak-Ball (JS Mode)", 17 ) |
| 1793 | | //PORT_CATEGORY_ITEM( 0x90, "Amiga Mouse", 18 ) |
| 1794 | | PORT_CATEGORY_CLASS( 0x0f, 0x00, "Right Controller" ) |
| 1855 | //PORT_CATEGORY_ITEM( 0x90, STR_AMIGAMOUSE, 15 ) |
| 1856 | PORT_CATEGORY_CLASS( 0x0f, 0x00, STR_RIGHT_CONTROLLER ) |
| 1795 | 1857 | PORT_CATEGORY_ITEM( 0x00, DEF_STR( Joystick ), 20 ) |
| 1796 | | PORT_CATEGORY_ITEM( 0x01, "Paddles", 21 ) |
| 1797 | | PORT_CATEGORY_ITEM( 0x02, "Driving", 22 ) |
| 1798 | | PORT_CATEGORY_ITEM( 0x03, "Keypad", 23 ) |
| 1799 | | //PORT_CATEGORY_ITEM( 0x04, "Lightgun", 24 ) |
| 1800 | | PORT_CATEGORY_ITEM( 0x05, "Booster Grip", 20 ) |
| 1801 | | //PORT_CATEGORY_ITEM( 0x06, "CX-22 Trak-Ball", 25 ) |
| 1802 | | //PORT_CATEGORY_ITEM( 0x07, "CX-80 Trak-Ball (TB Mode) / AtariST Mouse", 26 ) |
| 1858 | PORT_CATEGORY_ITEM( 0x01, STR_PADDLES, 21 ) |
| 1859 | PORT_CATEGORY_ITEM( 0x02, STR_DRIVING, 22 ) |
| 1860 | PORT_CATEGORY_ITEM( 0x03, STR_KEYPAD, 23 ) |
| 1861 | //PORT_CATEGORY_ITEM( 0x04, STR_LIGHTGUN, 24 ) |
| 1862 | PORT_CATEGORY_ITEM( 0x05, STR_BOOSTERGRIP, 20 ) |
| 1863 | //PORT_CATEGORY_ITEM( 0x06, STR_CX22TRAKBALL, 25 ) |
| 1864 | //PORT_CATEGORY_ITEM( 0x07, STR_CX80TRAKBALL, 25 ) |
| 1803 | 1865 | //PORT_CATEGORY_ITEM( 0x08, "CX-80 Trak-Ball (JS Mode)", 27 ) |
| 1804 | | //PORT_CATEGORY_ITEM( 0x09, "Amiga Mouse", 28 ) |
| 1805 | | PORT_CATEGORY_ITEM( 0x0a, "KidVid Voice Module", 30 ) |
| 1866 | //PORT_CATEGORY_ITEM( 0x09, STR_AMIGAMOUSE, 25 ) |
| 1867 | PORT_CATEGORY_ITEM( 0x0a, STR_KIDVID, 30 ) |
| 1806 | 1868 | //PORT_CATEGORY_ITEM( 0x0b, "Save Key", 31 ) |
| 1807 | 1869 | |
| 1808 | 1870 | PORT_START /* [10] left keypad */ |
| r897 | r898 | |
| 1839 | 1901 | PORT_START /* [13] right driving controller */ |
| 1840 | 1902 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_CATEGORY(22) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(2) |
| 1841 | 1903 | |
| 1842 | | // PORT_START /* [14] left light gun X */ |
| 1904 | PORT_START /* [14] left light gun X */ |
| 1843 | 1905 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CATEGORY(14) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1) |
| 1844 | 1906 | |
| 1845 | | // PORT_START /* [15] left light gun Y */ |
| 1907 | PORT_START /* [15] left light gun Y */ |
| 1846 | 1908 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CATEGORY(14) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(1) |
| 1847 | 1909 | |
| 1848 | | // PORT_START /* [16] right light gun X */ |
| 1910 | PORT_START /* [16] right light gun X */ |
| 1849 | 1911 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_X ) PORT_CATEGORY(24) PORT_CROSSHAIR( X, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(2) |
| 1850 | 1912 | |
| 1851 | | // PORT_START /* [17] right light gun Y */ |
| 1913 | PORT_START /* [17] right light gun Y */ |
| 1852 | 1914 | // PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CATEGORY(24) PORT_CROSSHAIR( Y, 1.0, 0.0, 0 ) PORT_SENSITIVITY(25) PORT_KEYDELTA(15) PORT_PLAYER(2) |
| 1915 | |
| 1916 | PORT_START /* [18] left trak ball X */ |
| 1917 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_CATEGORY(15) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(1) |
| 1918 | |
| 1919 | PORT_START /* [19] left trak ball Y */ |
| 1920 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_CATEGORY(15) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(1) |
| 1921 | |
| 1922 | PORT_START /* [20] right trak ball X */ |
| 1923 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_CATEGORY(25) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(2) |
| 1924 | |
| 1925 | PORT_START /* [21] right trak ball Y */ |
| 1926 | PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_CATEGORY(25) PORT_SENSITIVITY(40) PORT_KEYDELTA(5) PORT_PLAYER(2) |
| 1927 | |
| 1853 | 1928 | INPUT_PORTS_END |
| 1854 | 1929 | |
| 1855 | 1930 | |