summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/amiga.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/amiga.cpp')
-rw-r--r--src/mame/drivers/amiga.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/mame/drivers/amiga.cpp b/src/mame/drivers/amiga.cpp
index d19165cd21c..ec51d490bc1 100644
--- a/src/mame/drivers/amiga.cpp
+++ b/src/mame/drivers/amiga.cpp
@@ -552,7 +552,7 @@ public:
u16 handle_joystick_potgor(u16 potgor);
DECLARE_CUSTOM_INPUT_MEMBER( cd32_input );
- DECLARE_CUSTOM_INPUT_MEMBER( cd32_sel_mirror_input );
+ template <int P> DECLARE_READ_LINE_MEMBER( cd32_sel_mirror_input );
void init_pal();
void init_ntsc();
@@ -1146,9 +1146,10 @@ CUSTOM_INPUT_MEMBER( cd32_state::cd32_input )
return handle_joystick_potgor(m_potgo_value) >> 8;
}
-CUSTOM_INPUT_MEMBER( cd32_state::cd32_sel_mirror_input )
+template <int P>
+READ_LINE_MEMBER( cd32_state::cd32_sel_mirror_input )
{
- u8 bits = m_player_ports[(int)(uintptr_t)param]->read();
+ u8 bits = m_player_ports[P]->read();
return (bits & 0x20)>>5;
}
@@ -1459,6 +1460,22 @@ void a4000_state::a4000t_mem(address_map &map)
// INPUTS
//**************************************************************************
+template <int P>
+CUSTOM_INPUT_MEMBER( amiga_state::amiga_joystick_convert )
+{
+ uint8_t bits = m_joy_ports[P].read_safe(0xff);
+
+ int up = (bits >> 0) & 1;
+ int down = (bits >> 1) & 1;
+ int left = (bits >> 2) & 1;
+ int right = (bits >> 3) & 1;
+
+ if (left) up ^= 1;
+ if (right) down ^= 1;
+
+ return down | (right << 1) | (up << 8) | (left << 9);
+}
+
static INPUT_PORTS_START( amiga )
PORT_START("input")
PORT_CONFNAME(0x10, 0x00, "Game Port 0 Device")
@@ -1469,16 +1486,16 @@ static INPUT_PORTS_START( amiga )
PORT_CONFSETTING(0x20, DEF_STR(Joystick) )
PORT_START("cia_0_port_a")
- PORT_BIT(0x3f, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(DEVICE_SELF, amiga_state, floppy_drive_status, (void *)0)
+ PORT_BIT(0x3f, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(amiga_state, floppy_drive_status)
PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(1)
PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_PLAYER(2)
PORT_START("joy_0_dat")
- PORT_BIT(0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(DEVICE_SELF, amiga_state, amiga_joystick_convert, (void *)0)
+ PORT_BIT(0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(amiga_state, amiga_joystick_convert<0>)
PORT_BIT(0xfcfc, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("joy_1_dat")
- PORT_BIT(0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(DEVICE_SELF, amiga_state, amiga_joystick_convert, (void *)1)
+ PORT_BIT(0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_CUSTOM_MEMBER(amiga_state, amiga_joystick_convert<1>)
PORT_BIT(0xfcfc, IP_ACTIVE_HIGH, IPT_UNUSED)
PORT_START("potgo")
@@ -1519,19 +1536,19 @@ INPUT_PORTS_START( cd32 )
PORT_MODIFY("cia_0_port_a")
PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_CUSTOM )
// this is the regular port for reading a single button joystick on the Amiga, many CD32 games require this to mirror the pad start button!
- PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, cd32_state, cd32_sel_mirror_input, (void *)0)
- PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, cd32_state, cd32_sel_mirror_input, (void *)1)
+ PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(cd32_state, cd32_sel_mirror_input<0>)
+ PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_CUSTOM ) PORT_READ_LINE_MEMBER(cd32_state, cd32_sel_mirror_input<1>)
PORT_MODIFY("joy_0_dat")
- PORT_BIT( 0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, amiga_state, amiga_joystick_convert, (void *)0)
+ PORT_BIT( 0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(amiga_state, amiga_joystick_convert<0>)
PORT_BIT( 0xfcfc, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_MODIFY("joy_1_dat")
- PORT_BIT( 0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, amiga_state, amiga_joystick_convert, (void *)1)
+ PORT_BIT( 0x0303, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(amiga_state, amiga_joystick_convert<1>)
PORT_BIT( 0xfcfc, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_MODIFY("potgo")
- PORT_BIT( 0xff00, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(DEVICE_SELF, cd32_state, cd32_input, (void *)0)
+ PORT_BIT( 0xff00, IP_ACTIVE_HIGH, IPT_CUSTOM ) PORT_CUSTOM_MEMBER(cd32_state, cd32_input)
PORT_BIT( 0x00ff, IP_ACTIVE_HIGH, IPT_UNUSED )
// CD32 '11' button pad (4 dpad directions + 7 buttons), not read directly