Previous 15994 Revisions Next

r4464 Wednesday 8th April, 2009 at 01:55:59 UTC by Barry Rodewald
[X68000] Added support for 3-button Megadrive gamepad.
[src/mess/drivers]x68k.c
[src/mess/includes]x68k.h

src/mess/includes/x68k.h
r4463r4464
185185      char last_mouse_y;  // previous mouse y-axis value
186186      int bufferempty;  // non-zero if buffer is empty
187187   } mouse;
188   struct
189   {
190      // port A
191      int mux1;  // multiplexer value
192      int seq1;  // part of 6-button input sequence.
193      // port B
194      int mux2;  // multiplexer value
195      int seq2;  // part of 6-button input sequence.
196   } mdctrl;
188197};
189198
190199/*----------- defined in drivers/x68k.c -----------*/
src/mess/drivers/x68k.c
r4463r4464
679679   hd63450_set_timer(dev,3,ATTOTIME_IN_HZ(rate));
680680}
681681
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?)
685static 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}
682713
714
683715// Judging from the XM6 source code, PPI ports A and B are joystick inputs
684716static READ8_DEVICE_HANDLER( ppi_port_a_r )
685717{
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;
691732}
692733
693734static READ8_DEVICE_HANDLER( ppi_port_b_r )
694735{
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;
700750}
701751
702752static READ8_DEVICE_HANDLER( ppi_port_c_r )
r4463r4464
12371287static WRITE16_DEVICE_HANDLER( x68k_ppi_w )
12381288{
12391289   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   }
12401300}
12411301
12421302static READ16_DEVICE_HANDLER( x68k_ppi_r )
r4463r4464
16981758};
16991759
17001760static 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
17011772   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)
17101781
17111782   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)
17201791
17211792   PORT_START( "key1" )
17221793   PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_UNUSED) // unused
r4463r4464
18621933
18631934   PORT_START("mouse3")  // Y-axis
18641935   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)
18651946
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   
18661977INPUT_PORTS_END
18671978
18681979static void dimdsk_set_geometry(const device_config* image)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team