(MESS) c64/c128: Implemented parallel joystick pot X/Y read. [Curt Coder]

(MESS) vcsctrl: Removed runtime tag lookups. (nw)
This commit is contained in:
Curt Coder 2013-01-26 18:53:13 +00:00
parent 380368e16f
commit 31ddd3a1aa
17 changed files with 144 additions and 37 deletions

View File

@ -927,7 +927,20 @@ READ8_MEMBER( c128_state::sid_potx_r )
{
case 1: data = m_joy1->pot_x_r(); break;
case 2: data = m_joy2->pot_x_r(); break;
case 3: break; // TODO pot1 and pot2 in series
case 3:
if (m_joy1->has_pot_x() && m_joy2->has_pot_x())
{
data = 1 / (1 / m_joy1->pot_x_r() + 1 / m_joy2->pot_x_r());
}
else if (m_joy1->has_pot_x())
{
data = m_joy1->pot_x_r();
}
else if (m_joy2->has_pot_x())
{
data = m_joy2->pot_x_r();
}
break;
}
return data;
@ -941,7 +954,20 @@ READ8_MEMBER( c128_state::sid_poty_r )
{
case 1: data = m_joy1->pot_y_r(); break;
case 2: data = m_joy2->pot_y_r(); break;
case 3: break; // TODO pot1 and pot2 in series
case 3:
if (m_joy1->has_pot_y() && m_joy2->has_pot_y())
{
data = 1 / (1 / m_joy1->pot_y_r() + 1 / m_joy2->pot_y_r());
}
else if (m_joy1->has_pot_y())
{
data = m_joy1->pot_y_r();
}
else if (m_joy2->has_pot_y())
{
data = m_joy2->pot_y_r();
}
break;
}
return data;

View File

@ -8,14 +8,7 @@
- IRQ (WRONG $DC0D)
- NMI (WRONG $DD0D)
- some CIA tests
- 64C PLA dump
- Multiscreen crashes on boot
805A: lda $01
805C: and #$FE
805E: sta $01
8060: m6502_brk#$00 <-- BOOM!
*/
@ -512,7 +505,20 @@ READ8_MEMBER( c64_state::sid_potx_r )
{
case 1: data = m_joy1->pot_x_r(); break;
case 2: data = m_joy2->pot_x_r(); break;
case 3: break; // TODO pot1 and pot2 in series
case 3:
if (m_joy1->has_pot_x() && m_joy2->has_pot_x())
{
data = 1 / (1 / m_joy1->pot_x_r() + 1 / m_joy2->pot_x_r());
}
else if (m_joy1->has_pot_x())
{
data = m_joy1->pot_x_r();
}
else if (m_joy2->has_pot_x())
{
data = m_joy2->pot_x_r();
}
break;
}
return data;
@ -526,7 +532,20 @@ READ8_MEMBER( c64_state::sid_poty_r )
{
case 1: data = m_joy1->pot_y_r(); break;
case 2: data = m_joy2->pot_y_r(); break;
case 3: break; // TODO pot1 and pot2 in series
case 3:
if (m_joy1->has_pot_y() && m_joy2->has_pot_y())
{
data = 1 / (1 / m_joy1->pot_y_r() + 1 / m_joy2->pot_y_r());
}
else if (m_joy1->has_pot_y())
{
data = m_joy1->pot_y_r();
}
else if (m_joy2->has_pot_y())
{
data = m_joy2->pot_y_r();
}
break;
}
return data;

View File

@ -48,6 +48,12 @@
TODO:
- M6802 board
- crashes on boot
805A: lda $01
805C: and #$FE
805E: sta $01
8060: m6502_brk#$00 <-- BOOM!
*/

View File

@ -50,7 +50,8 @@ ioport_constructor vcs_joystick_device::device_input_ports() const
vcs_joystick_device::vcs_joystick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, VCS_JOYSTICK, "Digital joystick", tag, owner, clock),
device_vcs_control_port_interface(mconfig, *this)
device_vcs_control_port_interface(mconfig, *this),
m_joy(*this, "JOY")
{
}
@ -70,5 +71,5 @@ void vcs_joystick_device::device_start()
UINT8 vcs_joystick_device::vcs_joy_r()
{
return ioport("JOY")->read();
return m_joy->read();
}

View File

@ -41,6 +41,9 @@ protected:
// device_vcs_control_port_interface overrides
virtual UINT8 vcs_joy_r();
private:
required_ioport m_joy;
};

View File

@ -59,7 +59,10 @@ ioport_constructor vcs_joystick_booster_device::device_input_ports() const
vcs_joystick_booster_device::vcs_joystick_booster_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, VCS_JOYSTICK_BOOSTER, "Digital joystick with Boostergrip", tag, owner, clock),
device_vcs_control_port_interface(mconfig, *this)
device_vcs_control_port_interface(mconfig, *this),
m_joy(*this, "JOY"),
m_potx(*this, "POTX"),
m_poty(*this, "POTY")
{
}
@ -79,15 +82,15 @@ void vcs_joystick_booster_device::device_start()
UINT8 vcs_joystick_booster_device::vcs_joy_r()
{
return ioport("JOY")->read();
return m_joy->read();
}
UINT8 vcs_joystick_booster_device::vcs_pot_x_r()
{
return ioport("POTX")->read();
return m_potx->read();
}
UINT8 vcs_joystick_booster_device::vcs_pot_y_r()
{
return ioport("POTY")->read();
return m_poty->read();
}

View File

@ -44,6 +44,14 @@ protected:
virtual UINT8 vcs_joy_r();
virtual UINT8 vcs_pot_x_r();
virtual UINT8 vcs_pot_y_r();
virtual bool has_pot_x() { return true; }
virtual bool has_pot_y() { return true; }
private:
required_ioport m_joy;
required_ioport m_potx;
required_ioport m_poty;
};

View File

@ -56,7 +56,8 @@ ioport_constructor vcs_keypad_device::device_input_ports() const
vcs_keypad_device::vcs_keypad_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, VCS_KEYPAD, "Keypad", tag, owner, clock),
device_vcs_control_port_interface(mconfig, *this)
device_vcs_control_port_interface(mconfig, *this),
m_keypad(*this, "KEYPAD")
{
}
@ -82,7 +83,7 @@ UINT8 vcs_keypad_device::vcs_joy_r()
{
if ( ! ( ( m_column >> i ) & 0x01 ) )
{
if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x04 )
if ( ( m_keypad->read() >> 3*i ) & 0x04 )
{
return 0xff;
}
@ -106,7 +107,7 @@ UINT8 vcs_keypad_device::vcs_pot_x_r()
{
if ( ! ( ( m_column >> i ) & 0x01 ) )
{
if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x01 )
if ( ( m_keypad->read() >> 3*i ) & 0x01 )
{
return 0;
}
@ -125,7 +126,7 @@ UINT8 vcs_keypad_device::vcs_pot_y_r()
{
if ( ! ( ( m_column >> i ) & 0x01 ) )
{
if ( ( ioport("KEYPAD")->read() >> 3*i ) & 0x02 )
if ( ( m_keypad->read() >> 3*i ) & 0x02 )
{
return 0;
}

View File

@ -25,7 +25,7 @@
// ======================> vcs_keypad_device
class vcs_keypad_device : public device_t,
public device_vcs_control_port_interface
public device_vcs_control_port_interface
{
public:
// construction/destruction
@ -45,6 +45,12 @@ protected:
virtual UINT8 vcs_pot_x_r();
virtual UINT8 vcs_pot_y_r();
virtual bool has_pot_x() { return true; }
virtual bool has_pot_y() { return true; }
private:
required_ioport m_keypad;
UINT8 m_column;
};

View File

@ -58,7 +58,10 @@ ioport_constructor vcs_lightpen_device::device_input_ports() const
vcs_lightpen_device::vcs_lightpen_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, VCS_LIGHTPEN, "Light Pen", tag, owner, clock),
device_vcs_control_port_interface(mconfig, *this)
device_vcs_control_port_interface(mconfig, *this),
m_joy(*this, "JOY"),
m_lightx(*this, "LIGHTX"),
m_lighty(*this, "LIGHTY")
{
}
@ -78,5 +81,5 @@ void vcs_lightpen_device::device_start()
UINT8 vcs_lightpen_device::vcs_joy_r()
{
return ioport("JOY")->read();
return m_joy->read();
}

View File

@ -43,6 +43,11 @@ protected:
// device_vcs_control_port_interface overrides
virtual UINT8 vcs_joy_r();
private:
required_ioport m_joy;
required_ioport m_lightx;
required_ioport m_lighty;
};

View File

@ -53,7 +53,10 @@ ioport_constructor vcs_paddles_device::device_input_ports() const
vcs_paddles_device::vcs_paddles_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, VCS_PADDLES, "Digital paddles", tag, owner, clock),
device_vcs_control_port_interface(mconfig, *this)
device_vcs_control_port_interface(mconfig, *this),
m_joy(*this, "JOY"),
m_potx(*this, "POTX"),
m_poty(*this, "POTY")
{
}
@ -73,7 +76,7 @@ void vcs_paddles_device::device_start()
UINT8 vcs_paddles_device::vcs_joy_r()
{
return ioport("JOY")->read();
return m_joy->read();
}
@ -83,7 +86,7 @@ UINT8 vcs_paddles_device::vcs_joy_r()
UINT8 vcs_paddles_device::vcs_pot_x_r()
{
return ioport("POTX")->read();
return m_potx->read();
}
@ -93,5 +96,5 @@ UINT8 vcs_paddles_device::vcs_pot_x_r()
UINT8 vcs_paddles_device::vcs_pot_y_r()
{
return ioport("POTY")->read();
return m_poty->read();
}

View File

@ -43,6 +43,14 @@ protected:
virtual UINT8 vcs_joy_r();
virtual UINT8 vcs_pot_x_r();
virtual UINT8 vcs_pot_y_r();
virtual bool has_pot_x() { return true; }
virtual bool has_pot_y() { return true; }
private:
required_ioport m_joy;
required_ioport m_potx;
required_ioport m_poty;
};

View File

@ -49,7 +49,9 @@ ioport_constructor vcs_wheel_device::device_input_ports() const
vcs_wheel_device::vcs_wheel_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, VCS_WHEEL, "Driving Wheel", tag, owner, clock),
device_vcs_control_port_interface(mconfig, *this)
device_vcs_control_port_interface(mconfig, *this),
m_joy(*this, "JOY"),
m_wheel(*this, "WHEEL")
{
}
@ -71,5 +73,5 @@ UINT8 vcs_wheel_device::vcs_joy_r()
{
static const UINT8 driving_lookup[4] = { 0x00, 0x02, 0x03, 0x01 };
return ioport("JOY")->read() | driving_lookup[ ( ioport("WHEEL")->read() & 0x18 ) >> 3 ];
return m_joy->read() | driving_lookup[ ( m_wheel->read() & 0x18 ) >> 3 ];
}

View File

@ -41,6 +41,10 @@ protected:
// device_vcs_control_port_interface overrides
virtual UINT8 vcs_joy_r();
private:
required_ioport m_joy;
required_ioport m_wheel;
};

View File

@ -53,8 +53,8 @@ device_vcs_control_port_interface::~device_vcs_control_port_interface()
//-------------------------------------------------
vcs_control_port_device::vcs_control_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, VCS_CONTROL_PORT, "Atari VCS control port", tag, owner, clock),
device_slot_interface(mconfig, *this)
device_t(mconfig, VCS_CONTROL_PORT, "Atari VCS control port", tag, owner, clock),
device_slot_interface(mconfig, *this)
{
}
@ -78,15 +78,17 @@ void vcs_control_port_device::device_start()
}
UINT8 vcs_control_port_device::joy_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_joy_r(); return data; }
UINT8 vcs_control_port_device::joy_r() { UINT8 data = 0xff; if (exists()) data = m_device->vcs_joy_r(); return data; }
READ8_MEMBER( vcs_control_port_device::joy_r ) { return joy_r(); }
UINT8 vcs_control_port_device::pot_x_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_pot_x_r(); return data; }
UINT8 vcs_control_port_device::pot_x_r() { UINT8 data = 0xff; if (exists()) data = m_device->vcs_pot_x_r(); return data; }
READ8_MEMBER( vcs_control_port_device::pot_x_r ) { return pot_x_r(); }
UINT8 vcs_control_port_device::pot_y_r() { UINT8 data = 0xff; if (m_device != NULL) data = m_device->vcs_pot_y_r(); return data; }
UINT8 vcs_control_port_device::pot_y_r() { UINT8 data = 0xff; if (exists()) data = m_device->vcs_pot_y_r(); return data; }
READ8_MEMBER( vcs_control_port_device::pot_y_r ) { return pot_y_r(); }
void vcs_control_port_device::joy_w( UINT8 data ) { if ( m_device != NULL ) m_device->vcs_joy_w( data ); }
void vcs_control_port_device::joy_w( UINT8 data ) { if ( exists() ) m_device->vcs_joy_w( data ); }
WRITE8_MEMBER( vcs_control_port_device::joy_w ) { joy_w(data); }
bool vcs_control_port_device::exists() { return m_device != NULL; }
bool vcs_control_port_device::has_pot_x() { return exists() && m_device->has_pot_x(); }
bool vcs_control_port_device::has_pot_y() { return exists() && m_device->has_pot_y(); }
//-------------------------------------------------
// SLOT_INTERFACE( vcs_control_port_devices )

View File

@ -68,6 +68,10 @@ public:
void joy_w( UINT8 data );
DECLARE_WRITE8_MEMBER( joy_w );
bool exists();
bool has_pot_x();
bool has_pot_y();
protected:
// device-level overrides
virtual void device_start();
@ -91,6 +95,9 @@ public:
virtual UINT8 vcs_pot_y_r() { return 0xff; };
virtual void vcs_joy_w(UINT8 data) { };
virtual bool has_pot_x() { return false; }
virtual bool has_pot_y() { return false; }
protected:
vcs_control_port_device *m_port;
};