trunk/src/emu/bus/gamegear/gear2gear.c
| r0 | r242576 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Sega Game Gear "Gear to Gear Port" emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "gear2gear.h" |
| 11 | // slot devices |
| 12 | #include "smsctrladp.h" |
| 13 | |
| 14 | |
| 15 | |
| 16 | //************************************************************************** |
| 17 | // GLOBAL VARIABLES |
| 18 | //************************************************************************** |
| 19 | |
| 20 | const device_type GG_GEAR2GEAR_PORT = &device_creator<gg_gear2gear_port_device>; |
| 21 | |
| 22 | |
| 23 | |
| 24 | //************************************************************************** |
| 25 | // CARD INTERFACE |
| 26 | //************************************************************************** |
| 27 | |
| 28 | //------------------------------------------------- |
| 29 | // device_gg_gear2gear_port_interface - constructor |
| 30 | //------------------------------------------------- |
| 31 | |
| 32 | device_gg_gear2gear_port_interface::device_gg_gear2gear_port_interface(const machine_config &mconfig, device_t &device) |
| 33 | : device_slot_card_interface(mconfig,device) |
| 34 | { |
| 35 | m_port = dynamic_cast<gg_gear2gear_port_device *>(device.owner()); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | //------------------------------------------------- |
| 40 | // ~device_gg_gear2gear_port_interface - destructor |
| 41 | //------------------------------------------------- |
| 42 | |
| 43 | device_gg_gear2gear_port_interface::~device_gg_gear2gear_port_interface() |
| 44 | { |
| 45 | } |
| 46 | |
| 47 | |
| 48 | |
| 49 | //************************************************************************** |
| 50 | // LIVE DEVICE |
| 51 | //************************************************************************** |
| 52 | |
| 53 | //------------------------------------------------- |
| 54 | // gg_gear2gear_port_device - constructor |
| 55 | //------------------------------------------------- |
| 56 | |
| 57 | gg_gear2gear_port_device::gg_gear2gear_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 58 | device_t(mconfig, GG_GEAR2GEAR_PORT, "Gear to Gear Port", tag, owner, clock, "gg_gear2gear_port", __FILE__), |
| 59 | device_slot_interface(mconfig, *this), |
| 60 | m_th_pin_handler(*this), |
| 61 | m_pixel_handler(*this) |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | |
| 66 | //------------------------------------------------- |
| 67 | // gg_gear2gear_port_device - destructor |
| 68 | //------------------------------------------------- |
| 69 | |
| 70 | gg_gear2gear_port_device::~gg_gear2gear_port_device() |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | |
| 75 | //------------------------------------------------- |
| 76 | // device_start - device-specific startup |
| 77 | //------------------------------------------------- |
| 78 | |
| 79 | void gg_gear2gear_port_device::device_start() |
| 80 | { |
| 81 | m_device = dynamic_cast<device_gg_gear2gear_port_interface *>(get_card_device()); |
| 82 | |
| 83 | m_th_pin_handler.resolve_safe(); |
| 84 | m_pixel_handler.resolve_safe(0); |
| 85 | } |
| 86 | |
| 87 | |
| 88 | UINT8 gg_gear2gear_port_device::port_r() |
| 89 | { |
| 90 | UINT8 data = 0xff; |
| 91 | if (m_device) |
| 92 | data = m_device->peripheral_r(); |
| 93 | return data; |
| 94 | } |
| 95 | |
| 96 | void gg_gear2gear_port_device::port_w( UINT8 data ) |
| 97 | { |
| 98 | if (m_device) |
| 99 | m_device->peripheral_w(data); |
| 100 | } |
| 101 | |
| 102 | |
| 103 | void gg_gear2gear_port_device::th_pin_w(int state) |
| 104 | { |
| 105 | m_th_pin_handler(state); |
| 106 | } |
| 107 | |
| 108 | UINT32 gg_gear2gear_port_device::pixel_r() |
| 109 | { |
| 110 | return m_pixel_handler(); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | //------------------------------------------------- |
| 115 | // SLOT_INTERFACE( gg_gear2gear_port_devices ) |
| 116 | //------------------------------------------------- |
| 117 | |
| 118 | SLOT_INTERFACE_START( gg_gear2gear_port_devices ) |
| 119 | SLOT_INTERFACE("smsctrladp", SMS_CTRL_ADAPTOR) |
| 120 | SLOT_INTERFACE_END |
trunk/src/emu/bus/gamegear/gear2gear.h
| r0 | r242576 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Sega Game Gear "Gear to Gear Port" emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ********************************************************************** |
| 9 | |
| 10 | |
| 11 | **********************************************************************/ |
| 12 | |
| 13 | #pragma once |
| 14 | |
| 15 | #ifndef __GG_GEAR2GEAR_PORT__ |
| 16 | #define __GG_GEAR2GEAR_PORT__ |
| 17 | |
| 18 | #include "emu.h" |
| 19 | |
| 20 | |
| 21 | |
| 22 | //************************************************************************** |
| 23 | // INTERFACE CONFIGURATION MACROS |
| 24 | //************************************************************************** |
| 25 | |
| 26 | #define MCFG_GG_GEAR2GEAR_PORT_ADD(_tag, _slot_intf, _def_slot) \ |
| 27 | MCFG_DEVICE_ADD(_tag, GG_GEAR2GEAR_PORT, 0) \ |
| 28 | MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, false) |
| 29 | #define MCFG_GG_GEAR2GEAR_PORT_MODIFY(_tag) \ |
| 30 | MCFG_DEVICE_MODIFY(_tag) |
| 31 | |
| 32 | |
| 33 | #define MCFG_GG_GEAR2GEAR_PORT_TH_INPUT_HANDLER(_devcb) \ |
| 34 | devcb = &gg_gear2gear_port_device::set_th_input_handler(*device, DEVCB_##_devcb); |
| 35 | |
| 36 | |
| 37 | #define MCFG_GG_GEAR2GEAR_PORT_PIXEL_HANDLER(_devcb) \ |
| 38 | devcb = &gg_gear2gear_port_device::set_pixel_handler(*device, DEVCB_##_devcb); |
| 39 | |
| 40 | |
| 41 | |
| 42 | //************************************************************************** |
| 43 | // TYPE DEFINITIONS |
| 44 | //************************************************************************** |
| 45 | |
| 46 | // ======================> gg_gear2gear_port_device |
| 47 | |
| 48 | class device_gg_gear2gear_port_interface; |
| 49 | |
| 50 | class gg_gear2gear_port_device : public device_t, |
| 51 | public device_slot_interface |
| 52 | { |
| 53 | public: |
| 54 | // construction/destruction |
| 55 | gg_gear2gear_port_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 56 | virtual ~gg_gear2gear_port_device(); |
| 57 | |
| 58 | // static configuration helpers |
| 59 | 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); } |
| 60 | |
| 61 | 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); } |
| 62 | |
| 63 | // Currently, only the support for SMS Controller Adaptor is emulated, |
| 64 | // for when SMS Compatibility mode is enabled. In that mode, the 10 |
| 65 | // pins of the Gear to Gear Port follows the same numbering of a SMS |
| 66 | // Control port. |
| 67 | |
| 68 | // Data returned by the port_r methods: |
| 69 | // bit 0 - pin 1 - Up |
| 70 | // bit 1 - pin 2 - Down |
| 71 | // bit 2 - pin 3 - Left |
| 72 | // bit 3 - pin 4 - Right |
| 73 | // bit 4 - pin 5 - Vcc (no data) |
| 74 | // bit 5 - pin 6 - TL (Button 1/Light Phaser Trigger) |
| 75 | // bit 6 - pin 7 - TH (Light Phaser sensor) |
| 76 | // pin 8 - GND |
| 77 | // bit 7 - pin 9 - TR (Button 2) |
| 78 | // pin 10 - Not connected |
| 79 | // |
| 80 | UINT8 port_r(); |
| 81 | void port_w( UINT8 data ); |
| 82 | |
| 83 | void th_pin_w(int state); |
| 84 | UINT32 pixel_r(); |
| 85 | |
| 86 | //protected: |
| 87 | // device-level overrides |
| 88 | virtual void device_start(); |
| 89 | |
| 90 | device_gg_gear2gear_port_interface *m_device; |
| 91 | |
| 92 | private: |
| 93 | devcb_write_line m_th_pin_handler; |
| 94 | devcb_read32 m_pixel_handler; |
| 95 | }; |
| 96 | |
| 97 | |
| 98 | // ======================> device_gg_gear2gear_port_interface |
| 99 | |
| 100 | // class representing interface-specific live sms_expansion card |
| 101 | class device_gg_gear2gear_port_interface : public device_slot_card_interface |
| 102 | { |
| 103 | public: |
| 104 | // construction/destruction |
| 105 | device_gg_gear2gear_port_interface(const machine_config &mconfig, device_t &device); |
| 106 | virtual ~device_gg_gear2gear_port_interface(); |
| 107 | |
| 108 | virtual UINT8 peripheral_r() { return 0xff; }; |
| 109 | virtual void peripheral_w(UINT8 data) { }; |
| 110 | |
| 111 | protected: |
| 112 | gg_gear2gear_port_device *m_port; |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | // device type definition |
| 117 | extern const device_type GG_GEAR2GEAR_PORT; |
| 118 | |
| 119 | |
| 120 | SLOT_INTERFACE_EXTERN( gg_gear2gear_port_devices ); |
| 121 | |
| 122 | |
| 123 | #endif |
trunk/src/emu/bus/gamegear/smsctrladp.c
| r0 | r242576 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Sega Game Gear "Gear to Gear Port SMS Controller Adaptor" emulation |
| 4 | Also known as "Master Link" cable. |
| 5 | |
| 6 | Copyright MESS Team. |
| 7 | Visit http://mamedev.org for licensing and usage restrictions. |
| 8 | |
| 9 | **********************************************************************/ |
| 10 | |
| 11 | #include "smsctrladp.h" |
| 12 | |
| 13 | |
| 14 | |
| 15 | //************************************************************************** |
| 16 | // DEVICE DEFINITIONS |
| 17 | //************************************************************************** |
| 18 | |
| 19 | const device_type SMS_CTRL_ADAPTOR = &device_creator<sms_ctrl_adaptor_device>; |
| 20 | |
| 21 | |
| 22 | //************************************************************************** |
| 23 | // LIVE DEVICE |
| 24 | //************************************************************************** |
| 25 | |
| 26 | //------------------------------------------------- |
| 27 | // sms_ctrl_adaptor_device - constructor |
| 28 | //------------------------------------------------- |
| 29 | |
| 30 | sms_ctrl_adaptor_device::sms_ctrl_adaptor_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 31 | device_t(mconfig, SMS_CTRL_ADAPTOR, "SMS Controller Adaptor", tag, owner, clock, "sms_ctrl_adaptor", __FILE__), |
| 32 | device_gg_gear2gear_port_interface(mconfig, *this), |
| 33 | m_subctrl_port(*this, "ctrl") |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | |
| 38 | //------------------------------------------------- |
| 39 | // device_start - device-specific startup |
| 40 | //------------------------------------------------- |
| 41 | |
| 42 | void sms_ctrl_adaptor_device::device_start() |
| 43 | { |
| 44 | m_subctrl_port->device_start(); |
| 45 | } |
| 46 | |
| 47 | |
| 48 | //------------------------------------------------- |
| 49 | // sms_peripheral_r - rapid fire read |
| 50 | //------------------------------------------------- |
| 51 | |
| 52 | UINT8 sms_ctrl_adaptor_device::peripheral_r() |
| 53 | { |
| 54 | return m_subctrl_port->port_r(); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | //------------------------------------------------- |
| 59 | // sms_peripheral_w - rapid fire write |
| 60 | //------------------------------------------------- |
| 61 | |
| 62 | void sms_ctrl_adaptor_device::peripheral_w(UINT8 data) |
| 63 | { |
| 64 | m_subctrl_port->port_w(data); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | //------------------------------------------------- |
| 69 | // machine_config_additions - device-specific |
| 70 | // machine configurations |
| 71 | //------------------------------------------------- |
| 72 | |
| 73 | WRITE_LINE_MEMBER( sms_ctrl_adaptor_device::th_pin_w ) |
| 74 | { |
| 75 | m_port->th_pin_w(state); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | READ32_MEMBER( sms_ctrl_adaptor_device::pixel_r ) |
| 80 | { |
| 81 | return m_port->pixel_r(); |
| 82 | } |
| 83 | |
| 84 | |
| 85 | static MACHINE_CONFIG_FRAGMENT( sms_adp_slot ) |
| 86 | MCFG_SMS_CONTROL_PORT_ADD("ctrl", sms_control_port_devices, "joypad") |
| 87 | MCFG_SMS_CONTROL_PORT_TH_INPUT_HANDLER(WRITELINE(sms_ctrl_adaptor_device, th_pin_w)) |
| 88 | MCFG_SMS_CONTROL_PORT_PIXEL_HANDLER(READ32(sms_ctrl_adaptor_device, pixel_r)) |
| 89 | MACHINE_CONFIG_END |
| 90 | |
| 91 | |
| 92 | machine_config_constructor sms_ctrl_adaptor_device::device_mconfig_additions() const |
| 93 | { |
| 94 | return MACHINE_CONFIG_NAME( sms_adp_slot ); |
| 95 | } |
trunk/src/emu/bus/gamegear/smsctrladp.h
| r0 | r242576 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Sega Game Gear "Gear to Gear Port SMS Controller Adaptor" emulation |
| 4 | Also known as "Master Link" cable. |
| 5 | |
| 6 | Copyright MESS Team. |
| 7 | Visit http://mamedev.org for licensing and usage restrictions. |
| 8 | |
| 9 | **********************************************************************/ |
| 10 | |
| 11 | #pragma once |
| 12 | |
| 13 | #ifndef __SMS_CTRL_ADAPTOR__ |
| 14 | #define __SMS_CTRL_ADAPTOR__ |
| 15 | |
| 16 | |
| 17 | #include "emu.h" |
| 18 | #include "gear2gear.h" |
| 19 | #include "../sms_ctrl/smsctrl.h" |
| 20 | |
| 21 | |
| 22 | |
| 23 | //************************************************************************** |
| 24 | // TYPE DEFINITIONS |
| 25 | //************************************************************************** |
| 26 | |
| 27 | // ======================> sms_ctrl_adaptor_device |
| 28 | |
| 29 | class sms_ctrl_adaptor_device : public device_t, |
| 30 | public device_gg_gear2gear_port_interface |
| 31 | { |
| 32 | public: |
| 33 | // construction/destruction |
| 34 | sms_ctrl_adaptor_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 35 | |
| 36 | DECLARE_WRITE_LINE_MEMBER(th_pin_w); |
| 37 | DECLARE_READ32_MEMBER(pixel_r); |
| 38 | |
| 39 | protected: |
| 40 | // device-level overrides |
| 41 | virtual void device_start(); |
| 42 | virtual machine_config_constructor device_mconfig_additions() const; |
| 43 | |
| 44 | // device_gg_gear2gear_port_interface overrides |
| 45 | virtual UINT8 peripheral_r(); |
| 46 | virtual void peripheral_w(UINT8 data); |
| 47 | |
| 48 | private: |
| 49 | required_device<sms_control_port_device> m_subctrl_port; |
| 50 | }; |
| 51 | |
| 52 | |
| 53 | // device type definition |
| 54 | extern const device_type SMS_CTRL_ADAPTOR; |
| 55 | |
| 56 | |
| 57 | #endif |