1 // license:BSD-3-Clause 2 // copyright-holders:Fabio Priuli 3 /********************************************************************** 4 5 Sega Game Gear EXT port emulation 6 Also known as Gear-to-Gear (or VS, in Japan) cable connector 7 8 ********************************************************************** 9 10 11 **********************************************************************/ 12 13 #ifndef MAME_BUS_GAMEGEAR_GGEXT_H 14 #define MAME_BUS_GAMEGEAR_GGEXT_H 15 16 #pragma once 17 18 19 //************************************************************************** 20 // TYPE DEFINITIONS 21 //************************************************************************** 22 23 // ======================> gg_ext_port_device 24 25 class device_gg_ext_port_interface; 26 27 class gg_ext_port_device : public device_t, public device_single_card_slot_interface<device_gg_ext_port_interface> 28 { 29 public: 30 // construction/destruction 31 template <typename T> gg_ext_port_device(machine_config const & mconfig,char const * tag,device_t * owner,T && opts,char const * dflt)32 gg_ext_port_device(machine_config const &mconfig, char const *tag, device_t *owner, T &&opts, char const *dflt) 33 : gg_ext_port_device(mconfig, tag, owner, 0) 34 { 35 option_reset(); 36 opts(*this); 37 set_default_option(dflt); 38 set_fixed(false); 39 } 40 41 gg_ext_port_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); 42 virtual ~gg_ext_port_device(); 43 44 // static configuration helpers th_input_handler()45 auto th_input_handler() { return m_th_pin_handler.bind(); } 46 47 // Currently, only the support for SMS Controller Adaptor is emulated, 48 // for when SMS Compatibility mode is enabled. In that mode, the 10 pins 49 // of the EXT port follows the same numbering of a SMS Control port. 50 51 // Data returned by the port_r methods: 52 // bit 0 - pin 1 - Up 53 // bit 1 - pin 2 - Down 54 // bit 2 - pin 3 - Left 55 // bit 3 - pin 4 - Right 56 // bit 4 - pin 5 - Vcc (no data) 57 // bit 5 - pin 6 - TL (Button 1/Light Phaser Trigger) 58 // bit 6 - pin 7 - TH (Light Phaser sensor) 59 // pin 8 - GND 60 // bit 7 - pin 9 - TR (Button 2) 61 // pin 10 - Not connected 62 // 63 uint8_t port_r(); 64 void port_w( uint8_t data ); 65 66 void th_pin_w(int state); 67 set_screen_tag(T && tag)68 template <typename T> void set_screen_tag(T &&tag) { m_screen.set_tag(std::forward<T>(tag)); } 69 70 // for peripherals that interact with the machine's screen 71 required_device<screen_device> m_screen; 72 73 //protected: 74 // device-level overrides 75 virtual void device_start() override; 76 77 device_gg_ext_port_interface *m_device; 78 79 private: 80 devcb_write_line m_th_pin_handler; 81 }; 82 83 84 // ======================> device_gg_ext_port_interface 85 86 // class representing interface-specific live sms_expansion card 87 class device_gg_ext_port_interface : public device_interface 88 { 89 public: 90 // construction/destruction 91 virtual ~device_gg_ext_port_interface(); 92 peripheral_r()93 virtual uint8_t peripheral_r() { return 0xff; } peripheral_w(uint8_t data)94 virtual void peripheral_w(uint8_t data) { } 95 96 protected: 97 device_gg_ext_port_interface(const machine_config &mconfig, device_t &device); 98 99 gg_ext_port_device *m_port; 100 }; 101 102 103 // device type definition 104 DECLARE_DEVICE_TYPE(GG_EXT_PORT, gg_ext_port_device) 105 106 107 void gg_ext_port_devices(device_slot_interface &device); 108 109 #endif // MAME_BUS_GAMEGEAR_GGEXT_H 110