mirror of
https://github.com/holub/mame
synced 2025-05-28 08:33:05 +03:00
adding the new sourcefiles would have helped probably... ;)
This commit is contained in:
parent
3d2ff28471
commit
1ec4af617a
120
src/emu/bus/gamegear/gear2gear.c
Normal file
120
src/emu/bus/gamegear/gear2gear.c
Normal file
@ -0,0 +1,120 @@
|
||||
/**********************************************************************
|
||||
|
||||
Sega Game Gear "Gear to Gear Port" emulation
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "gear2gear.h"
|
||||
// slot devices
|
||||
#include "smsctrladp.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// GLOBAL VARIABLES
|
||||
//**************************************************************************
|
||||
|
||||
const device_type GG_GEAR2GEAR_PORT = &device_creator<gg_gear2gear_port_device>;
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// CARD INTERFACE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_gg_gear2gear_port_interface - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
device_gg_gear2gear_port_interface::device_gg_gear2gear_port_interface(const machine_config &mconfig, device_t &device)
|
||||
: device_slot_card_interface(mconfig,device)
|
||||
{
|
||||
m_port = dynamic_cast<gg_gear2gear_port_device *>(device.owner());
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// ~device_gg_gear2gear_port_interface - destructor
|
||||
//-------------------------------------------------
|
||||
|
||||
device_gg_gear2gear_port_interface::~device_gg_gear2gear_port_interface()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// gg_gear2gear_port_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
gg_gear2gear_port_device::gg_gear2gear_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, GG_GEAR2GEAR_PORT, "Gear to Gear Port", tag, owner, clock, "gg_gear2gear_port", __FILE__),
|
||||
device_slot_interface(mconfig, *this),
|
||||
m_th_pin_handler(*this),
|
||||
m_pixel_handler(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// gg_gear2gear_port_device - destructor
|
||||
//-------------------------------------------------
|
||||
|
||||
gg_gear2gear_port_device::~gg_gear2gear_port_device()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void gg_gear2gear_port_device::device_start()
|
||||
{
|
||||
m_device = dynamic_cast<device_gg_gear2gear_port_interface *>(get_card_device());
|
||||
|
||||
m_th_pin_handler.resolve_safe();
|
||||
m_pixel_handler.resolve_safe(0);
|
||||
}
|
||||
|
||||
|
||||
UINT8 gg_gear2gear_port_device::port_r()
|
||||
{
|
||||
UINT8 data = 0xff;
|
||||
if (m_device)
|
||||
data = m_device->peripheral_r();
|
||||
return data;
|
||||
}
|
||||
|
||||
void gg_gear2gear_port_device::port_w( UINT8 data )
|
||||
{
|
||||
if (m_device)
|
||||
m_device->peripheral_w(data);
|
||||
}
|
||||
|
||||
|
||||
void gg_gear2gear_port_device::th_pin_w(int state)
|
||||
{
|
||||
m_th_pin_handler(state);
|
||||
}
|
||||
|
||||
UINT32 gg_gear2gear_port_device::pixel_r()
|
||||
{
|
||||
return m_pixel_handler();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// SLOT_INTERFACE( gg_gear2gear_port_devices )
|
||||
//-------------------------------------------------
|
||||
|
||||
SLOT_INTERFACE_START( gg_gear2gear_port_devices )
|
||||
SLOT_INTERFACE("smsctrladp", SMS_CTRL_ADAPTOR)
|
||||
SLOT_INTERFACE_END
|
123
src/emu/bus/gamegear/gear2gear.h
Normal file
123
src/emu/bus/gamegear/gear2gear.h
Normal file
@ -0,0 +1,123 @@
|
||||
/**********************************************************************
|
||||
|
||||
Sega Game Gear "Gear to Gear Port" emulation
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************
|
||||
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __GG_GEAR2GEAR_PORT__
|
||||
#define __GG_GEAR2GEAR_PORT__
|
||||
|
||||
#include "emu.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// INTERFACE CONFIGURATION MACROS
|
||||
//**************************************************************************
|
||||
|
||||
#define MCFG_GG_GEAR2GEAR_PORT_ADD(_tag, _slot_intf, _def_slot) \
|
||||
MCFG_DEVICE_ADD(_tag, GG_GEAR2GEAR_PORT, 0) \
|
||||
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false)
|
||||
#define MCFG_GG_GEAR2GEAR_PORT_MODIFY(_tag) \
|
||||
MCFG_DEVICE_MODIFY(_tag)
|
||||
|
||||
|
||||
#define MCFG_GG_GEAR2GEAR_PORT_TH_INPUT_HANDLER(_devcb) \
|
||||
devcb = &gg_gear2gear_port_device::set_th_input_handler(*device, DEVCB_##_devcb);
|
||||
|
||||
|
||||
#define MCFG_GG_GEAR2GEAR_PORT_PIXEL_HANDLER(_devcb) \
|
||||
devcb = &gg_gear2gear_port_device::set_pixel_handler(*device, DEVCB_##_devcb);
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> gg_gear2gear_port_device
|
||||
|
||||
class device_gg_gear2gear_port_interface;
|
||||
|
||||
class gg_gear2gear_port_device : public device_t,
|
||||
public device_slot_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
gg_gear2gear_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
virtual ~gg_gear2gear_port_device();
|
||||
|
||||
// static configuration helpers
|
||||
template<class _Object> static devcb_base &set_th_input_handler(device_t &device, _Object object) { return downcast<gg_gear2gear_port_device &>(device).m_th_pin_handler.set_callback(object); }
|
||||
|
||||
template<class _Object> static devcb_base &set_pixel_handler(device_t &device, _Object object) { return downcast<gg_gear2gear_port_device &>(device).m_pixel_handler.set_callback(object); }
|
||||
|
||||
// Currently, only the support for SMS Controller Adaptor is emulated,
|
||||
// for when SMS Compatibility mode is enabled. In that mode, the 10
|
||||
// pins of the Gear to Gear Port follows the same numbering of a SMS
|
||||
// Control port.
|
||||
|
||||
// Data returned by the port_r methods:
|
||||
// bit 0 - pin 1 - Up
|
||||
// bit 1 - pin 2 - Down
|
||||
// bit 2 - pin 3 - Left
|
||||
// bit 3 - pin 4 - Right
|
||||
// bit 4 - pin 5 - Vcc (no data)
|
||||
// bit 5 - pin 6 - TL (Button 1/Light Phaser Trigger)
|
||||
// bit 6 - pin 7 - TH (Light Phaser sensor)
|
||||
// pin 8 - GND
|
||||
// bit 7 - pin 9 - TR (Button 2)
|
||||
// pin 10 - Not connected
|
||||
//
|
||||
UINT8 port_r();
|
||||
void port_w( UINT8 data );
|
||||
|
||||
void th_pin_w(int state);
|
||||
UINT32 pixel_r();
|
||||
|
||||
//protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
|
||||
device_gg_gear2gear_port_interface *m_device;
|
||||
|
||||
private:
|
||||
devcb_write_line m_th_pin_handler;
|
||||
devcb_read32 m_pixel_handler;
|
||||
};
|
||||
|
||||
|
||||
// ======================> device_gg_gear2gear_port_interface
|
||||
|
||||
// class representing interface-specific live sms_expansion card
|
||||
class device_gg_gear2gear_port_interface : public device_slot_card_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
device_gg_gear2gear_port_interface(const machine_config &mconfig, device_t &device);
|
||||
virtual ~device_gg_gear2gear_port_interface();
|
||||
|
||||
virtual UINT8 peripheral_r() { return 0xff; };
|
||||
virtual void peripheral_w(UINT8 data) { };
|
||||
|
||||
protected:
|
||||
gg_gear2gear_port_device *m_port;
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
extern const device_type GG_GEAR2GEAR_PORT;
|
||||
|
||||
|
||||
SLOT_INTERFACE_EXTERN( gg_gear2gear_port_devices );
|
||||
|
||||
|
||||
#endif
|
95
src/emu/bus/gamegear/smsctrladp.c
Normal file
95
src/emu/bus/gamegear/smsctrladp.c
Normal file
@ -0,0 +1,95 @@
|
||||
/**********************************************************************
|
||||
|
||||
Sega Game Gear "Gear to Gear Port SMS Controller Adaptor" emulation
|
||||
Also known as "Master Link" cable.
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "smsctrladp.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// DEVICE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
const device_type SMS_CTRL_ADAPTOR = &device_creator<sms_ctrl_adaptor_device>;
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// LIVE DEVICE
|
||||
//**************************************************************************
|
||||
|
||||
//-------------------------------------------------
|
||||
// sms_ctrl_adaptor_device - constructor
|
||||
//-------------------------------------------------
|
||||
|
||||
sms_ctrl_adaptor_device::sms_ctrl_adaptor_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, SMS_CTRL_ADAPTOR, "SMS Controller Adaptor", tag, owner, clock, "sms_ctrl_adaptor", __FILE__),
|
||||
device_gg_gear2gear_port_interface(mconfig, *this),
|
||||
m_subctrl_port(*this, "ctrl")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// device_start - device-specific startup
|
||||
//-------------------------------------------------
|
||||
|
||||
void sms_ctrl_adaptor_device::device_start()
|
||||
{
|
||||
m_subctrl_port->device_start();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// sms_peripheral_r - rapid fire read
|
||||
//-------------------------------------------------
|
||||
|
||||
UINT8 sms_ctrl_adaptor_device::peripheral_r()
|
||||
{
|
||||
return m_subctrl_port->port_r();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// sms_peripheral_w - rapid fire write
|
||||
//-------------------------------------------------
|
||||
|
||||
void sms_ctrl_adaptor_device::peripheral_w(UINT8 data)
|
||||
{
|
||||
m_subctrl_port->port_w(data);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// machine_config_additions - device-specific
|
||||
// machine configurations
|
||||
//-------------------------------------------------
|
||||
|
||||
WRITE_LINE_MEMBER( sms_ctrl_adaptor_device::th_pin_w )
|
||||
{
|
||||
m_port->th_pin_w(state);
|
||||
}
|
||||
|
||||
|
||||
READ32_MEMBER( sms_ctrl_adaptor_device::pixel_r )
|
||||
{
|
||||
return m_port->pixel_r();
|
||||
}
|
||||
|
||||
|
||||
static MACHINE_CONFIG_FRAGMENT( sms_adp_slot )
|
||||
MCFG_SMS_CONTROL_PORT_ADD("ctrl", sms_control_port_devices, "joypad")
|
||||
MCFG_SMS_CONTROL_PORT_TH_INPUT_HANDLER(WRITELINE(sms_ctrl_adaptor_device, th_pin_w))
|
||||
MCFG_SMS_CONTROL_PORT_PIXEL_HANDLER(READ32(sms_ctrl_adaptor_device, pixel_r))
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
|
||||
machine_config_constructor sms_ctrl_adaptor_device::device_mconfig_additions() const
|
||||
{
|
||||
return MACHINE_CONFIG_NAME( sms_adp_slot );
|
||||
}
|
57
src/emu/bus/gamegear/smsctrladp.h
Normal file
57
src/emu/bus/gamegear/smsctrladp.h
Normal file
@ -0,0 +1,57 @@
|
||||
/**********************************************************************
|
||||
|
||||
Sega Game Gear "Gear to Gear Port SMS Controller Adaptor" emulation
|
||||
Also known as "Master Link" cable.
|
||||
|
||||
Copyright MESS Team.
|
||||
Visit http://mamedev.org for licensing and usage restrictions.
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __SMS_CTRL_ADAPTOR__
|
||||
#define __SMS_CTRL_ADAPTOR__
|
||||
|
||||
|
||||
#include "emu.h"
|
||||
#include "gear2gear.h"
|
||||
#include "../sms_ctrl/smsctrl.h"
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
||||
// ======================> sms_ctrl_adaptor_device
|
||||
|
||||
class sms_ctrl_adaptor_device : public device_t,
|
||||
public device_gg_gear2gear_port_interface
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
sms_ctrl_adaptor_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
|
||||
|
||||
DECLARE_WRITE_LINE_MEMBER(th_pin_w);
|
||||
DECLARE_READ32_MEMBER(pixel_r);
|
||||
|
||||
protected:
|
||||
// device-level overrides
|
||||
virtual void device_start();
|
||||
virtual machine_config_constructor device_mconfig_additions() const;
|
||||
|
||||
// device_gg_gear2gear_port_interface overrides
|
||||
virtual UINT8 peripheral_r();
|
||||
virtual void peripheral_w(UINT8 data);
|
||||
|
||||
private:
|
||||
required_device<sms_control_port_device> m_subctrl_port;
|
||||
};
|
||||
|
||||
|
||||
// device type definition
|
||||
extern const device_type SMS_CTRL_ADAPTOR;
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user