mirror of
https://github.com/holub/mame
synced 2025-04-23 17:00:53 +03:00
Added 4 controller support for N64/N64DD, as well as rough mouse support. You can select the device on each controller port.
This commit is contained in:
parent
a640d83341
commit
e115dff18a
@ -15,6 +15,8 @@ UINT32 *rsp_dmem;
|
||||
// device type definition
|
||||
const device_type N64PERIPH = &device_creator<n64_periphs>;
|
||||
|
||||
int mouse_dx = 0, mouse_dy = 0, mouse_x2 = 0, mouse_y2 = 0, mouse_cntx = 0, mouse_cnty = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1709,18 +1711,28 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
// Read status
|
||||
rdata[0] = 0x05;
|
||||
rdata[1] = 0x00;
|
||||
rdata[2] = 0x01;
|
||||
return 0;
|
||||
}
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
// Read status (unconnected)
|
||||
return 1;
|
||||
// Read status
|
||||
switch ((machine().root_device().ioport("input")->read() >> (2 * channel)) & 3)
|
||||
{
|
||||
case 0: //NONE (unconnected)
|
||||
case 3: //Invalid
|
||||
return 1;
|
||||
|
||||
case 1: //JOYPAD
|
||||
rdata[0] = 0x05;
|
||||
rdata[1] = 0x00;
|
||||
rdata[2] = 0x01;
|
||||
return 0;
|
||||
|
||||
case 2: //MOUSE
|
||||
rdata[0] = 0x02;
|
||||
rdata[1] = 0x00;
|
||||
rdata[2] = 0x01;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
@ -1744,9 +1756,11 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
|
||||
case 0x01: // Read button values
|
||||
{
|
||||
UINT16 buttons = 0;
|
||||
INT8 x = 0, y = 0;
|
||||
/* add here tags for P3 and P4 when implemented */
|
||||
static const char *const portnames[] = { "P1", "P1_ANALOG_X", "P1_ANALOG_Y", "P2", "P2_ANALOG_X", "P2_ANALOG_Y" };
|
||||
int x = 0, y = 0;
|
||||
static const char *const portnames[] = { "P1", "P1_ANALOG_X", "P1_ANALOG_Y", "P1_MOUSE_X", "P1_MOUSE_Y",
|
||||
"P2", "P2_ANALOG_X", "P2_ANALOG_Y", "P2_MOUSE_X", "P2_MOUSE_Y",
|
||||
"P3", "P3_ANALOG_X", "P3_ANALOG_Y", "P3_MOUSE_X", "P3_MOUSE_Y",
|
||||
"P4", "P4_ANALOG_X", "P4_ANALOG_Y", "P4_MOUSE_X", "P4_MOUSE_Y" };
|
||||
|
||||
if (slength != 1 || rlength != 4)
|
||||
{
|
||||
@ -1757,22 +1771,83 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
|
||||
{
|
||||
case 0: // P1 Inputs
|
||||
case 1: // P2 Inputs
|
||||
case 2: // P3 Inputs
|
||||
case 3: // P4 Inputs
|
||||
{
|
||||
buttons = machine().root_device().ioport(portnames[(channel*3) + 0])->read();
|
||||
x = machine().root_device().ioport(portnames[(channel*3) + 1])->read() - 128;
|
||||
y = machine().root_device().ioport(portnames[(channel*3) + 2])->read() - 128;
|
||||
switch ((machine().root_device().ioport("input")->read() >> (2 * channel)) & 3)
|
||||
{
|
||||
case 0: //NONE
|
||||
case 3: //Invalid
|
||||
return 1;
|
||||
|
||||
rdata[0] = (buttons >> 8) & 0xff;
|
||||
rdata[1] = (buttons >> 0) & 0xff;
|
||||
rdata[2] = (UINT8)(x);
|
||||
rdata[3] = (UINT8)(y);
|
||||
return 0;
|
||||
}
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
// P3/P4 Inputs (not connected)
|
||||
return 1;
|
||||
case 1: //JOYPAD
|
||||
buttons = machine().root_device().ioport(portnames[(channel*5) + 0])->read();
|
||||
x = machine().root_device().ioport(portnames[(channel*5) + 1])->read() - 128;
|
||||
y = machine().root_device().ioport(portnames[(channel*5) + 2])->read() - 128;
|
||||
|
||||
rdata[0] = (buttons >> 8) & 0xff;
|
||||
rdata[1] = (buttons >> 0) & 0xff;
|
||||
rdata[2] = (UINT8)(x);
|
||||
rdata[3] = (UINT8)(y);
|
||||
return 0;
|
||||
|
||||
case 2: //MOUSE
|
||||
buttons = machine().root_device().ioport(portnames[(channel*5) + 0])->read();
|
||||
x = machine().root_device().ioport(portnames[(channel*5) + 1 + 2])->read() - 128;
|
||||
y = machine().root_device().ioport(portnames[(channel*5) + 2 + 2])->read() - 128;
|
||||
|
||||
//x /= 4;
|
||||
//y /= 4;
|
||||
|
||||
if (x != mouse_x2)
|
||||
{
|
||||
mouse_dx = x - mouse_x2;
|
||||
|
||||
if (mouse_dx > 0x40)
|
||||
mouse_dx = (0x80) - mouse_dx;
|
||||
else if (mouse_dx < -0x40)
|
||||
mouse_dx = -(0x80) - mouse_dx;
|
||||
|
||||
mouse_cntx = mouse_dx;
|
||||
mouse_x2 = x;
|
||||
}
|
||||
|
||||
if (y != mouse_y2)
|
||||
{
|
||||
mouse_dy = y - mouse_y2;
|
||||
|
||||
if (mouse_dy > 0x40)
|
||||
mouse_dy = (0x80) - mouse_dy;
|
||||
else if (mouse_dy < -0x40)
|
||||
mouse_dy = -(0x80) - mouse_dy;
|
||||
|
||||
mouse_cnty = mouse_dy;
|
||||
mouse_y2 = y;
|
||||
}
|
||||
|
||||
if (mouse_cntx)
|
||||
{
|
||||
if(mouse_cntx < 0)
|
||||
mouse_cntx++;
|
||||
else
|
||||
mouse_cntx--;
|
||||
}
|
||||
|
||||
if (mouse_cnty)
|
||||
{
|
||||
if(mouse_cnty < 0)
|
||||
mouse_cnty++;
|
||||
else
|
||||
mouse_cnty--;
|
||||
}
|
||||
|
||||
rdata[0] = (buttons >> 8) & 0xff;
|
||||
rdata[1] = (buttons >> 0) & 0xff;
|
||||
rdata[2] = (UINT8)(mouse_cntx);
|
||||
rdata[3] = (UINT8)(mouse_cnty);
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,9 +88,28 @@ static ADDRESS_MAP_START( rsp_map, AS_PROGRAM, 32, n64_mess_state )
|
||||
ADDRESS_MAP_END
|
||||
|
||||
static INPUT_PORTS_START( n64 )
|
||||
PORT_START("input")
|
||||
PORT_CONFNAME(0x03, 0x01, "Controller Port 0 Device")
|
||||
PORT_CONFSETTING(0x00, "None")
|
||||
PORT_CONFSETTING(0x01, "Joypad")
|
||||
PORT_CONFSETTING(0x02, "Mouse")
|
||||
PORT_CONFNAME(0x0C, 0x00, "Controller Port 1 Device")
|
||||
PORT_CONFSETTING(0x00, "None")
|
||||
PORT_CONFSETTING(0x04, "Joypad")
|
||||
PORT_CONFSETTING(0x08, "Mouse")
|
||||
PORT_CONFNAME(0x30, 0x00, "Controller Port 2 Device")
|
||||
PORT_CONFSETTING(0x00, "None")
|
||||
PORT_CONFSETTING(0x10, "Joypad")
|
||||
PORT_CONFSETTING(0x20, "Mouse")
|
||||
PORT_CONFNAME(0xC0, 0x00, "Controller Port 3 Device")
|
||||
PORT_CONFSETTING(0x00, "None")
|
||||
PORT_CONFSETTING(0x40, "Joypad")
|
||||
PORT_CONFSETTING(0x80, "Mouse")
|
||||
|
||||
//Player 1
|
||||
PORT_START("P1")
|
||||
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Button A")
|
||||
PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Button B")
|
||||
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Button A / Left Click")
|
||||
PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Button B / Right Click")
|
||||
PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("P1 Button Z")
|
||||
PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(1) PORT_NAME("P1 Start")
|
||||
PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1) PORT_NAME("P1 Joypad \xE2\x86\x91") /* Up */
|
||||
@ -111,9 +130,16 @@ static INPUT_PORTS_START( n64 )
|
||||
PORT_START("P1_ANALOG_Y")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(1) PORT_REVERSE
|
||||
|
||||
PORT_START("P1_MOUSE_X")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_X ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1)
|
||||
|
||||
PORT_START("P1_MOUSE_Y")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_Y ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_REVERSE
|
||||
|
||||
//Player 2
|
||||
PORT_START("P2")
|
||||
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Button A")
|
||||
PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Button B")
|
||||
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Button A / Left Click")
|
||||
PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Button B / Right Click")
|
||||
PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 Button Z")
|
||||
PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(2) PORT_NAME("P2 Start")
|
||||
PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2) PORT_NAME("P2 Joypad \xE2\x86\x91") /* Up */
|
||||
@ -134,6 +160,72 @@ static INPUT_PORTS_START( n64 )
|
||||
PORT_START("P2_ANALOG_Y")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(2) PORT_REVERSE
|
||||
|
||||
PORT_START("P2_MOUSE_X")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_X ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(2)
|
||||
|
||||
PORT_START("P2_MOUSE_Y")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_Y ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(2) PORT_REVERSE
|
||||
|
||||
//Player 3
|
||||
PORT_START("P3")
|
||||
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(3) PORT_NAME("P3 Button A / Left Click")
|
||||
PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(3) PORT_NAME("P3 Button B / Right Click")
|
||||
PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(3) PORT_NAME("P3 Button Z")
|
||||
PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(3) PORT_NAME("P3 Start")
|
||||
PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(3) PORT_NAME("P3 Joypad \xE2\x86\x91") /* Up */
|
||||
PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(3) PORT_NAME("P3 Joypad \xE2\x86\x93") /* Down */
|
||||
PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(3) PORT_NAME("P3 Joypad \xE2\x86\x90") /* Left */
|
||||
PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(3) PORT_NAME("P3 Joypad \xE2\x86\x92") /* Right */
|
||||
PORT_BIT( 0x00c0, IP_ACTIVE_HIGH, IPT_UNUSED )
|
||||
PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(3) PORT_NAME("P3 Button L")
|
||||
PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(3) PORT_NAME("P3 Button R")
|
||||
PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(3) PORT_NAME("P3 Button C \xE2\x86\x91") /* Up */
|
||||
PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_PLAYER(3) PORT_NAME("P3 Button C \xE2\x86\x93") /* Down */
|
||||
PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_PLAYER(3) PORT_NAME("P3 Button C \xE2\x86\x90") /* Left */
|
||||
PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_PLAYER(3) PORT_NAME("P3 Button C \xE2\x86\x92") /* Right */
|
||||
|
||||
PORT_START("P3_ANALOG_X")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(3)
|
||||
|
||||
PORT_START("P3_ANALOG_Y")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(3) PORT_REVERSE
|
||||
|
||||
PORT_START("P3_MOUSE_X")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_X ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(3)
|
||||
|
||||
PORT_START("P3_MOUSE_Y")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_Y ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(3) PORT_REVERSE
|
||||
|
||||
//Player 4
|
||||
PORT_START("P4")
|
||||
PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(4) PORT_NAME("P4 Button A / Left Click")
|
||||
PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(4) PORT_NAME("P4 Button B / Right Click")
|
||||
PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(4) PORT_NAME("P4 Button Z")
|
||||
PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_START ) PORT_PLAYER(4) PORT_NAME("P4 Start")
|
||||
PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(4) PORT_NAME("P4 Joypad \xE2\x86\x91") /* Up */
|
||||
PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(4) PORT_NAME("P4 Joypad \xE2\x86\x93") /* Down */
|
||||
PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(4) PORT_NAME("P4 Joypad \xE2\x86\x90") /* Left */
|
||||
PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(4) PORT_NAME("P4 Joypad \xE2\x86\x92") /* Right */
|
||||
PORT_BIT( 0x00c0, IP_ACTIVE_HIGH, IPT_UNUSED )
|
||||
PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(4) PORT_NAME("P4 Button L")
|
||||
PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(4) PORT_NAME("P4 Button R")
|
||||
PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(4) PORT_NAME("P4 Button C \xE2\x86\x91") /* Up */
|
||||
PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_PLAYER(4) PORT_NAME("P4 Button C \xE2\x86\x93") /* Down */
|
||||
PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_PLAYER(4) PORT_NAME("P4 Button C \xE2\x86\x90") /* Left */
|
||||
PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_PLAYER(4) PORT_NAME("P4 Button C \xE2\x86\x92") /* Right */
|
||||
|
||||
PORT_START("P4_ANALOG_X")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(4)
|
||||
|
||||
PORT_START("P4_ANALOG_Y")
|
||||
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_MINMAX(0x00,0xff) PORT_SENSITIVITY(30) PORT_KEYDELTA(30) PORT_PLAYER(4) PORT_REVERSE
|
||||
|
||||
PORT_START("P4_MOUSE_X")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_X ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(4)
|
||||
|
||||
PORT_START("P4_MOUSE_Y")
|
||||
PORT_BIT( 0xffff, 0x0000, IPT_MOUSE_Y ) PORT_MINMAX(0x0000,0xffff) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(4) PORT_REVERSE
|
||||
|
||||
PORT_START("RESET")
|
||||
PORT_BIT( 0xfffe, IP_ACTIVE_HIGH, IPT_UNUSED )
|
||||
PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Warm Reset") PORT_CODE(KEYCODE_3)
|
||||
|
Loading…
Reference in New Issue
Block a user