1 // license:LGPL-2.1+ 2 // copyright-holders:Michael Zapf 3 /**************************************************************************** 4 5 Joystick port 6 7 Now explicitly implemented as a slot device 8 A joystick port allows for plugging in a single or twin joystick, or 9 a Mechatronics mouse. 10 11 The TI-99/4 also offers an infrared handset, connected to this port. For 12 this reason we also need an interrupt line. 13 14 Michael Zapf 15 16 June 2012 17 18 *****************************************************************************/ 19 20 #ifndef MAME_BUS_TI99_JOYPORT_JOYPORT_H 21 #define MAME_BUS_TI99_JOYPORT_JOYPORT_H 22 23 #pragma once 24 25 namespace bus { namespace ti99 { namespace joyport { 26 27 enum 28 { 29 PLAIN=0, 30 MOUSE, 31 HANDSET 32 }; 33 34 #define TI_JOYPORT_TAG "joyport" 35 36 class joyport_device; 37 38 /******************************************************************** 39 Common parent class of all devices attached to the joystick port 40 ********************************************************************/ 41 class device_ti99_joyport_interface : public device_interface 42 { 43 public: 44 virtual uint8_t read_dev() = 0; 45 virtual void write_dev(uint8_t data) = 0; pulse_clock()46 virtual void pulse_clock() { } 47 48 protected: 49 device_ti99_joyport_interface(const machine_config &mconfig, device_t &device); 50 51 virtual void interface_config_complete() override; 52 joyport_device* m_joyport; 53 }; 54 55 /******************************************************************** 56 Joystick port 57 ********************************************************************/ 58 class joyport_device : public device_t, public device_single_card_slot_interface<device_ti99_joyport_interface> 59 { 60 public: 61 template <typename U> joyport_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock,U && opts,const char * dflt)62 joyport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, U &&opts, const char *dflt) 63 : joyport_device(mconfig, tag, owner, clock) 64 { 65 option_reset(); 66 opts(*this); 67 set_default_option(dflt); 68 set_fixed(false); 69 } 70 71 joyport_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 72 uint8_t read_port(); 73 void write_port(int data); 74 void set_interrupt(int state); 75 void pulse_clock(); int_cb()76 auto int_cb() { return m_interrupt.bind(); } 77 78 protected: 79 void device_start() override; 80 void device_config_complete() override; 81 82 private: 83 devcb_write_line m_interrupt; 84 device_ti99_joyport_interface* m_connected; 85 }; 86 87 } } } // end namespace bus::ti99::joyport 88 89 DECLARE_DEVICE_TYPE_NS(TI99_JOYPORT, bus::ti99::joyport, joyport_device) 90 91 void ti99_joyport_options_plain(device_slot_interface &device); 92 void ti99_joyport_options_mouse(device_slot_interface &device); 93 void ti99_joyport_options_994(device_slot_interface &device); 94 95 #endif // MAME_BUS_TI99_JOYPORT_JOYPORT_H 96