src/mess/drivers/x68k.c
| r4463 | r4464 | |
| 679 | 679 | hd63450_set_timer(dev,3,ATTOTIME_IN_HZ(rate)); |
| 680 | 680 | } |
| 681 | 681 | |
| 682 | // Megadrive 3 button gamepad |
| 683 | // Multiplexer is controlled by bit 0 in the PPI control port |
| 684 | // According to XM6, bits 4 and 7 are always 1 (is this correct?) |
| 685 | static UINT8 md_3button_r(const device_config* device, int port) |
| 686 | { |
| 687 | if(port == 1) |
| 688 | { |
| 689 | if(x68k_sys.mdctrl.mux1 & 0x01) |
| 690 | { |
| 691 | return input_port_read(device->machine,"md3b_0") | 0x90; |
| 692 | } |
| 693 | else |
| 694 | { |
| 695 | return (input_port_read(device->machine,"md3b_1") & 0x60) | |
| 696 | (input_port_read(device->machine,"md3b_0") & 0x03) | 0x90; |
| 697 | } |
| 698 | } |
| 699 | if(port == 2) |
| 700 | { |
| 701 | if(x68k_sys.mdctrl.mux2 & 0x01) |
| 702 | { |
| 703 | return input_port_read(device->machine,"md3b_2") | 0x90; |
| 704 | } |
| 705 | else |
| 706 | { |
| 707 | return (input_port_read(device->machine,"md3b_3") & 0x60) | |
| 708 | (input_port_read(device->machine,"md3b_2") & 0x03) | 0x90; |
| 709 | } |
| 710 | } |
| 711 | return 0xff; |
| 712 | } |
| 682 | 713 | |
| 714 | |
| 683 | 715 | // Judging from the XM6 source code, PPI ports A and B are joystick inputs |
| 684 | 716 | static READ8_DEVICE_HANDLER( ppi_port_a_r ) |
| 685 | 717 | { |
| 686 | | // Joystick 1 |
| 687 | | if(x68k_sys.joy.joy1_enable == 0) |
| 688 | | return input_port_read(device->machine, "joy1"); |
| 689 | | else |
| 690 | | return 0xff; |
| 718 | int ctrl = input_port_read(device->machine,"ctrltype") & 0x0f; |
| 719 | |
| 720 | switch(ctrl) |
| 721 | { |
| 722 | case 0x00: // standard MSX/FM-Towns joystick |
| 723 | if(x68k_sys.joy.joy1_enable == 0) |
| 724 | return input_port_read(device->machine, "joy1"); |
| 725 | else |
| 726 | return 0xff; |
| 727 | case 0x01: // 3-button Megadrive gamepad |
| 728 | return md_3button_r(device,1); |
| 729 | } |
| 730 | |
| 731 | return 0xff; |
| 691 | 732 | } |
| 692 | 733 | |
| 693 | 734 | static READ8_DEVICE_HANDLER( ppi_port_b_r ) |
| 694 | 735 | { |
| 695 | | // Joystick 2 |
| 696 | | if(x68k_sys.joy.joy2_enable == 0) |
| 697 | | return input_port_read(device->machine, "joy2"); |
| 698 | | else |
| 699 | | return 0xff; |
| 736 | int ctrl = input_port_read(device->machine,"ctrltype") & 0xf0; |
| 737 | |
| 738 | switch(ctrl) |
| 739 | { |
| 740 | case 0x00: // standard MSX/FM-Towns joystick |
| 741 | if(x68k_sys.joy.joy2_enable == 0) |
| 742 | return input_port_read(device->machine, "joy2"); |
| 743 | else |
| 744 | return 0xff; |
| 745 | case 0x10: // 3-button Megadrive gamepad |
| 746 | return md_3button_r(device,2); |
| 747 | } |
| 748 | |
| 749 | return 0xff; |
| 700 | 750 | } |
| 701 | 751 | |
| 702 | 752 | static READ8_DEVICE_HANDLER( ppi_port_c_r ) |
| r4463 | r4464 | |
| 1237 | 1287 | static WRITE16_DEVICE_HANDLER( x68k_ppi_w ) |
| 1238 | 1288 | { |
| 1239 | 1289 | ppi8255_w(device,offset & 0x03,data); |
| 1290 | |
| 1291 | // It appears that bit 0 of the PPI control port also controls the |
| 1292 | // Megadrive controller multiplexer, with bit 1 determining which port. |
| 1293 | if(offset == 0x03) |
| 1294 | { |
| 1295 | if(data & 0x02) // 0 = port A, 1 = port B |
| 1296 | x68k_sys.mdctrl.mux2 = data & 0x01; |
| 1297 | else |
| 1298 | x68k_sys.mdctrl.mux1 = data & 0x01; |
| 1299 | } |
| 1240 | 1300 | } |
| 1241 | 1301 | |
| 1242 | 1302 | static READ16_DEVICE_HANDLER( x68k_ppi_r ) |
| r4463 | r4464 | |
| 1698 | 1758 | }; |
| 1699 | 1759 | |
| 1700 | 1760 | static INPUT_PORTS_START( x68000 ) |
| 1761 | PORT_START("ctrltype") |
| 1762 | PORT_CATEGORY_CLASS(0x0f,0x00,"Joystick Port 1") |
| 1763 | PORT_CATEGORY_ITEM(0x00,"Standard 2-button MSX/FM-Towns joystick",10) |
| 1764 | PORT_CATEGORY_ITEM(0x01,"3-button Megadrive gamepad",11) |
| 1765 | // PORT_CATEGORY_ITEM(0x02,"6-button Megadrive gamepad",12) |
| 1766 | PORT_CATEGORY_CLASS(0xf0,0x00,"Joystick Port 2") |
| 1767 | PORT_CATEGORY_ITEM(0x00,"Standard 2-button MSX/FM-Towns joystick",20) |
| 1768 | PORT_CATEGORY_ITEM(0x10,"3-button Megadrive gamepad",21) |
| 1769 | // PORT_CATEGORY_ITEM(0x20,"6-button Megadrive gamepad",22) |
| 1770 | // TODO: Sharp Cyber Stick (CZ-8NJ2) support |
| 1771 | |
| 1701 | 1772 | PORT_START( "joy1" ) |
| 1702 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_PLAYER(1) |
| 1703 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(1) |
| 1704 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_PLAYER(1) |
| 1705 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) |
| 1706 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1707 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(JOYCODE_BUTTON1) PORT_PLAYER(1) |
| 1708 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(JOYCODE_BUTTON2) PORT_PLAYER(1) |
| 1709 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1773 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_PLAYER(1) PORT_CATEGORY(10) |
| 1774 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(1) PORT_CATEGORY(10) |
| 1775 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_PLAYER(1) PORT_CATEGORY(10) |
| 1776 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(1) PORT_CATEGORY(10) |
| 1777 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(10) |
| 1778 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(JOYCODE_BUTTON1) PORT_PLAYER(1) PORT_CATEGORY(10) |
| 1779 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(JOYCODE_BUTTON2) PORT_PLAYER(1) PORT_CATEGORY(10) |
| 1780 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(10) |
| 1710 | 1781 | |
| 1711 | 1782 | PORT_START( "joy2" ) |
| 1712 | | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_PLAYER(2) |
| 1713 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) |
| 1714 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_PLAYER(2) |
| 1715 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(2) |
| 1716 | | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1717 | | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(JOYCODE_BUTTON1) PORT_PLAYER(2) |
| 1718 | | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(JOYCODE_BUTTON2) PORT_PLAYER(2) |
| 1719 | | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 1783 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_PLAYER(2) PORT_CATEGORY(20) |
| 1784 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_CATEGORY(20) |
| 1785 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_PLAYER(2) PORT_CATEGORY(20) |
| 1786 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(2) PORT_CATEGORY(20) |
| 1787 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(20) |
| 1788 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CODE(JOYCODE_BUTTON1) PORT_PLAYER(2) PORT_CATEGORY(20) |
| 1789 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CODE(JOYCODE_BUTTON2) PORT_PLAYER(2) PORT_CATEGORY(20) |
| 1790 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(20) |
| 1720 | 1791 | |
| 1721 | 1792 | PORT_START( "key1" ) |
| 1722 | 1793 | PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_UNUSED) // unused |
| r4463 | r4464 | |
| 1862 | 1933 | |
| 1863 | 1934 | PORT_START("mouse3") // Y-axis |
| 1864 | 1935 | PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) |
| 1936 | |
| 1937 | PORT_START("md3b_0") |
| 1938 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_NAME("MD Pad 1 Up") PORT_8WAY PORT_PLAYER(1) PORT_CATEGORY(11) |
| 1939 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_NAME("MD Pad 1 Down") PORT_8WAY PORT_PLAYER(1) PORT_CATEGORY(11) |
| 1940 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_NAME("MD Pad 1 Left") PORT_8WAY PORT_PLAYER(1) PORT_CATEGORY(11) |
| 1941 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_NAME("MD Pad 1 Right") PORT_8WAY PORT_PLAYER(1) PORT_CATEGORY(11) |
| 1942 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1943 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("MD Pad 1 B Button") PORT_CATEGORY(11) |
| 1944 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("MD Pad 1 C Button") PORT_CATEGORY(11) |
| 1945 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1865 | 1946 | |
| 1947 | PORT_START("md3b_1") |
| 1948 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1949 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1950 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1951 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1952 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1953 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("MD Pad 1 A Button") PORT_CATEGORY(11) |
| 1954 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_START ) PORT_PLAYER(1) PORT_NAME("MD Pad 1 Start Button") PORT_CATEGORY(11) |
| 1955 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(11) |
| 1956 | |
| 1957 | PORT_START("md3b_2") |
| 1958 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_NAME("MD Pad 2 Up") PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(21) |
| 1959 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_NAME("MD Pad 2 Down") PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(21) |
| 1960 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_NAME("MD Pad 2 Left") PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(21) |
| 1961 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_NAME("MD Pad 2 Right") PORT_8WAY PORT_PLAYER(2) PORT_CATEGORY(21) |
| 1962 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1963 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("MD Pad 2 B Button") PORT_CATEGORY(21) |
| 1964 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("MD Pad 2 C Button") PORT_CATEGORY(21) |
| 1965 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1966 | |
| 1967 | PORT_START("md3b_3") |
| 1968 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1969 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1970 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1971 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1972 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1973 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("MD Pad 2 A Button") PORT_CATEGORY(21) |
| 1974 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_START ) PORT_PLAYER(2) PORT_NAME("MD Pad 2 Start Button") PORT_CATEGORY(21) |
| 1975 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_CATEGORY(21) |
| 1976 | |
| 1866 | 1977 | INPUT_PORTS_END |
| 1867 | 1978 | |
| 1868 | 1979 | static void dimdsk_set_geometry(const device_config* image) |