trunk/src/emu/bus/a8sio/a8sio.c
| r0 | r242654 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Wilbert Pol |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | a8sio.h - Atari 8 bit SIO bus interface |
| 6 | |
| 7 | |
| 8 | 1 1 |
| 9 | 2 4 6 8 0 2 |
| 10 | +-----------+ |
| 11 | / o o o o o o \ |
| 12 | / o o o o o o o \ |
| 13 | +-----------------+ |
| 14 | 1 3 5 7 9 1 1 |
| 15 | 1 3 |
| 16 | |
| 17 | 1 - clock in (to computer) |
| 18 | 2 - clock out |
| 19 | 3 - data in |
| 20 | 4 - GND |
| 21 | 5 - data out |
| 22 | 6 - GND |
| 23 | 7 - command (active low) |
| 24 | 8 - motor |
| 25 | 9 - proceed (active low) |
| 26 | 10 - +5V/ready |
| 27 | 11 - audio in |
| 28 | 12 - +12V (A400/A800) |
| 29 | 13 - interrupt (active low) |
| 30 | |
| 31 | ***************************************************************************/ |
| 32 | |
| 33 | #include "emu.h" |
| 34 | #include "a8sio.h" |
| 35 | #include "cassette.h" |
| 36 | |
| 37 | |
| 38 | //************************************************************************** |
| 39 | // GLOBAL VARIABLES |
| 40 | //************************************************************************** |
| 41 | |
| 42 | const device_type A8SIO_SLOT = &device_creator<a8sio_slot_device>; |
| 43 | |
| 44 | //************************************************************************** |
| 45 | // LIVE DEVICE |
| 46 | //************************************************************************** |
| 47 | |
| 48 | //------------------------------------------------- |
| 49 | // a8sio_slot_device - constructor |
| 50 | //------------------------------------------------- |
| 51 | a8sio_slot_device::a8sio_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 52 | : device_t(mconfig, A8SIO_SLOT, "Atari 8 bit SIO Slot", tag, owner, clock, "a8sio_slot", __FILE__) |
| 53 | , device_slot_interface(mconfig, *this) |
| 54 | { |
| 55 | } |
| 56 | |
| 57 | a8sio_slot_device::a8sio_slot_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : |
| 58 | device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 59 | device_slot_interface(mconfig, *this) |
| 60 | { |
| 61 | } |
| 62 | |
| 63 | void a8sio_slot_device::static_set_a8sio_slot(device_t &device, const char *tag, const char *slottag) |
| 64 | { |
| 65 | a8sio_slot_device &a8sio_ext = dynamic_cast<a8sio_slot_device &>(device); |
| 66 | a8sio_ext.m_a8sio_tag = tag; |
| 67 | a8sio_ext.m_a8sio_slottag = slottag; |
| 68 | } |
| 69 | |
| 70 | //------------------------------------------------- |
| 71 | // device_start - device-specific startup |
| 72 | //------------------------------------------------- |
| 73 | |
| 74 | void a8sio_slot_device::device_start() |
| 75 | { |
| 76 | device_a8sio_card_interface *dev = dynamic_cast<device_a8sio_card_interface *>(get_card_device()); |
| 77 | |
| 78 | if (dev) |
| 79 | { |
| 80 | device_a8sio_card_interface::static_set_a8sio_tag(*dev, m_a8sio_tag, m_a8sio_slottag); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | |
| 85 | |
| 86 | //************************************************************************** |
| 87 | // GLOBAL VARIABLES |
| 88 | //************************************************************************** |
| 89 | |
| 90 | const device_type A8SIO = &device_creator<a8sio_device>; |
| 91 | |
| 92 | |
| 93 | //************************************************************************** |
| 94 | // LIVE DEVICE |
| 95 | //************************************************************************** |
| 96 | |
| 97 | //------------------------------------------------- |
| 98 | // a8sio_device - constructor |
| 99 | //------------------------------------------------- |
| 100 | |
| 101 | a8sio_device::a8sio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 102 | : device_t(mconfig, A8SIO, "Atari 8 biot SIO", tag, owner, clock, "a8sio", __FILE__) |
| 103 | , m_out_clock_in_cb(*this) |
| 104 | , m_out_data_in_cb(*this) |
| 105 | , m_out_audio_in_cb(*this) |
| 106 | { |
| 107 | } |
| 108 | |
| 109 | a8sio_device::a8sio_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) |
| 110 | : device_t(mconfig, type, name, tag, owner, clock, shortname, source) |
| 111 | , m_out_clock_in_cb(*this) |
| 112 | , m_out_data_in_cb(*this) |
| 113 | , m_out_audio_in_cb(*this) |
| 114 | { |
| 115 | } |
| 116 | |
| 117 | //------------------------------------------------- |
| 118 | // device_start - device-specific startup |
| 119 | //------------------------------------------------- |
| 120 | |
| 121 | void a8sio_device::device_start() |
| 122 | { |
| 123 | // resolve callbacks |
| 124 | m_out_clock_in_cb.resolve_safe(); |
| 125 | m_out_data_in_cb.resolve_safe(); |
| 126 | m_out_audio_in_cb.resolve_safe(); |
| 127 | |
| 128 | // clear slot |
| 129 | m_device = NULL; |
| 130 | } |
| 131 | |
| 132 | //------------------------------------------------- |
| 133 | // device_reset - device-specific reset |
| 134 | //------------------------------------------------- |
| 135 | |
| 136 | void a8sio_device::device_reset() |
| 137 | { |
| 138 | } |
| 139 | |
| 140 | device_a8sio_card_interface *a8sio_device::get_a8sio_card() |
| 141 | { |
| 142 | return m_device; |
| 143 | } |
| 144 | |
| 145 | void a8sio_device::add_a8sio_card(device_a8sio_card_interface *card) |
| 146 | { |
| 147 | m_device = card; |
| 148 | } |
| 149 | |
| 150 | WRITE_LINE_MEMBER( a8sio_device::clock_in_w ) |
| 151 | { |
| 152 | m_out_clock_in_cb(state); |
| 153 | } |
| 154 | |
| 155 | WRITE_LINE_MEMBER( a8sio_device::data_in_w ) |
| 156 | { |
| 157 | m_out_data_in_cb(state); |
| 158 | } |
| 159 | |
| 160 | WRITE_LINE_MEMBER( a8sio_device::motor_w ) |
| 161 | { |
| 162 | if (m_device) |
| 163 | { |
| 164 | m_device->motor_w(state); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | WRITE8_MEMBER( a8sio_device::audio_in_w ) |
| 169 | { |
| 170 | m_out_audio_in_cb(data); |
| 171 | } |
| 172 | |
| 173 | |
| 174 | //************************************************************************** |
| 175 | // DEVICE A8SIO CARD INTERFACE |
| 176 | //************************************************************************** |
| 177 | |
| 178 | //------------------------------------------------- |
| 179 | // device_a8sio_card_interface - constructor |
| 180 | //------------------------------------------------- |
| 181 | |
| 182 | device_a8sio_card_interface::device_a8sio_card_interface(const machine_config &mconfig, device_t &device) |
| 183 | : device_slot_card_interface(mconfig, device) |
| 184 | , m_a8sio(NULL) |
| 185 | , m_a8sio_tag(NULL) |
| 186 | { |
| 187 | } |
| 188 | |
| 189 | |
| 190 | //------------------------------------------------- |
| 191 | // ~device_a8sio_card_interface - destructor |
| 192 | //------------------------------------------------- |
| 193 | |
| 194 | device_a8sio_card_interface::~device_a8sio_card_interface() |
| 195 | { |
| 196 | } |
| 197 | |
| 198 | void device_a8sio_card_interface::static_set_a8sio_tag(device_t &device, const char *tag, const char *slottag) |
| 199 | { |
| 200 | device_a8sio_card_interface &a8sio_card = dynamic_cast<device_a8sio_card_interface &>(device); |
| 201 | a8sio_card.m_a8sio_tag = tag; |
| 202 | a8sio_card.m_a8sio_slottag = slottag; |
| 203 | } |
| 204 | |
| 205 | void device_a8sio_card_interface::set_a8sio_device() |
| 206 | { |
| 207 | m_a8sio = dynamic_cast<a8sio_device *>(device().machine().device(m_a8sio_tag)); |
| 208 | m_a8sio->add_a8sio_card(this); |
| 209 | } |
| 210 | |
| 211 | WRITE_LINE_MEMBER( device_a8sio_card_interface::motor_w ) |
| 212 | { |
| 213 | //printf("device_a8sio_card_interface::motor_w %d\n", state); |
| 214 | } |
| 215 | |
| 216 | |
| 217 | SLOT_INTERFACE_START(a8sio_cards) |
| 218 | SLOT_INTERFACE("cassette", A8SIO_CASSETTE) |
| 219 | SLOT_INTERFACE_END |
| 220 | |
trunk/src/emu/bus/a8sio/a8sio.h
| r0 | r242654 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Wilbert Pol |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | a8sio.h - Atari 8 bit SIO bus interface |
| 6 | |
| 7 | |
| 8 | 1 1 |
| 9 | 2 4 6 8 0 2 |
| 10 | +-----------+ |
| 11 | / o o o o o o \ |
| 12 | / o o o o o o o \ |
| 13 | +-----------------+ |
| 14 | 1 3 5 7 9 1 1 |
| 15 | 1 3 |
| 16 | |
| 17 | 1 - clock in (to computer) |
| 18 | 2 - clock out |
| 19 | 3 - data in |
| 20 | 4 - GND |
| 21 | 5 - data out |
| 22 | 6 - GND |
| 23 | 7 - command (active low) |
| 24 | 8 - motor |
| 25 | 9 - proceed (active low) |
| 26 | 10 - +5V/ready |
| 27 | 11 - audio in |
| 28 | 12 - +12V (A400/A800) |
| 29 | 13 - interrupt (active low) |
| 30 | |
| 31 | ***************************************************************************/ |
| 32 | |
| 33 | #pragma once |
| 34 | |
| 35 | #ifndef __A8SIO_H_ |
| 36 | #define __A8SIO_H_ |
| 37 | |
| 38 | |
| 39 | //************************************************************************** |
| 40 | // INTERFACE CONFIGURATION MACROS |
| 41 | //************************************************************************** |
| 42 | |
| 43 | #define MCFG_A8SIO_SLOT_ADD(_nbtag, _tag, _def_slot) \ |
| 44 | MCFG_DEVICE_ADD(_tag, A8SIO_SLOT, 0) \ |
| 45 | MCFG_DEVICE_SLOT_INTERFACE(a8sio_cards, _def_slot, false) \ |
| 46 | a8sio_slot_device::static_set_a8sio_slot(*device, _nbtag, _tag); |
| 47 | |
| 48 | |
| 49 | class a8sio_slot_device : public device_t, |
| 50 | public device_slot_interface |
| 51 | { |
| 52 | public: |
| 53 | // construction/destruction |
| 54 | a8sio_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 55 | a8sio_slot_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); |
| 56 | |
| 57 | // device-level overrides |
| 58 | virtual void device_start(); |
| 59 | |
| 60 | // inline configuration |
| 61 | static void static_set_a8sio_slot(device_t &device, const char *tag, const char *slottag); |
| 62 | |
| 63 | protected: |
| 64 | // configuration |
| 65 | const char *m_a8sio_tag; |
| 66 | const char *m_a8sio_slottag; |
| 67 | }; |
| 68 | |
| 69 | |
| 70 | // device type definition |
| 71 | extern const device_type A8SIO_SLOT; |
| 72 | |
| 73 | |
| 74 | class device_a8sio_card_interface; |
| 75 | |
| 76 | class a8sio_device : public device_t |
| 77 | { |
| 78 | public: |
| 79 | // construction/destruction |
| 80 | a8sio_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 81 | a8sio_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); |
| 82 | |
| 83 | // inline configuration |
| 84 | template<class _Object> static devcb_base &set_clock_in_callback(device_t &device, _Object object) { return downcast<a8sio_device &>(device).m_out_clock_in_cb.set_callback(object); } |
| 85 | template<class _Object> static devcb_base &set_data_in_callback(device_t &device, _Object object) { return downcast<a8sio_device &>(device).m_out_data_in_cb.set_callback(object); } |
| 86 | template<class _Object> static devcb_base &set_audio_in_callback(device_t &device, _Object object) { return downcast<a8sio_device &>(device).m_out_audio_in_cb.set_callback(object); } |
| 87 | |
| 88 | void add_a8sio_card(device_a8sio_card_interface *card); |
| 89 | device_a8sio_card_interface *get_a8sio_card(); |
| 90 | |
| 91 | DECLARE_WRITE_LINE_MEMBER( clock_in_w ); // pin 1 |
| 92 | //virtual DECLARE_WRITE_LINE_MEMBER( clock_out_w ); // pin 2 |
| 93 | DECLARE_WRITE_LINE_MEMBER( data_in_w ); // pin 3 |
| 94 | //DECLARE_WRITE_LINE_MEMBER( data_out_wi ); // pin 5 |
| 95 | //DECLARE_WRITE_LINE_MEMBER( command_w ); // pin 7 |
| 96 | DECLARE_WRITE_LINE_MEMBER( motor_w ); // pin 8 |
| 97 | //DECLARE_WRITE_LINE_MEMBER( proceed_w ); // pin 9 |
| 98 | DECLARE_WRITE8_MEMBER( audio_in_w ); // pin 11 |
| 99 | |
| 100 | protected: |
| 101 | // device-level overrides |
| 102 | virtual void device_start(); |
| 103 | virtual void device_reset(); |
| 104 | |
| 105 | devcb_write_line m_out_clock_in_cb; // pin 1 |
| 106 | devcb_write_line m_out_data_in_cb; // pin 3 |
| 107 | devcb_write8 m_out_audio_in_cb; // pin 11 |
| 108 | |
| 109 | device_a8sio_card_interface *m_device; |
| 110 | }; |
| 111 | |
| 112 | |
| 113 | // device type definition |
| 114 | extern const device_type A8SIO; |
| 115 | |
| 116 | |
| 117 | class device_a8sio_card_interface : public device_slot_card_interface |
| 118 | { |
| 119 | friend class a8sio_device; |
| 120 | public: |
| 121 | // construction/destruction |
| 122 | device_a8sio_card_interface(const machine_config &mconfig, device_t &device); |
| 123 | virtual ~device_a8sio_card_interface(); |
| 124 | |
| 125 | void set_a8sio_device(); |
| 126 | |
| 127 | // inline configuration |
| 128 | static void static_set_a8sio_tag(device_t &device, const char *tag, const char *slottag); |
| 129 | |
| 130 | virtual DECLARE_WRITE_LINE_MEMBER( motor_w ); |
| 131 | |
| 132 | public: |
| 133 | a8sio_device *m_a8sio; |
| 134 | const char *m_a8sio_tag; |
| 135 | const char *m_a8sio_slottag; |
| 136 | }; |
| 137 | |
| 138 | |
| 139 | SLOT_INTERFACE_EXTERN(a8sio_cards); |
| 140 | |
| 141 | #endif |
trunk/src/emu/bus/a8sio/cassette.c
| r0 | r242654 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Wilbert Pol |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | cassette.h - Atari 8 bit cassette player(s) |
| 6 | |
| 7 | |
| 8 | Known cassette players: |
| 9 | - Atari XC11 |
| 10 | - Atari XC12 (no SIO connection for an additional device) |
| 11 | |
| 12 | TODO: |
| 13 | - Implement cassette reading |
| 14 | - Implement cassette writing |
| 15 | - Add audio support |
| 16 | - Add SIO connector for a next device |
| 17 | |
| 18 | ***************************************************************************/ |
| 19 | |
| 20 | #include "emu.h" |
| 21 | #include "cassette.h" |
| 22 | |
| 23 | |
| 24 | //************************************************************************** |
| 25 | // GLOBAL VARIABLES |
| 26 | //************************************************************************** |
| 27 | |
| 28 | const device_type A8SIO_CASSETTE = &device_creator<a8sio_cassette_device>; |
| 29 | |
| 30 | static MACHINE_CONFIG_FRAGMENT( cassette ) |
| 31 | MCFG_CASSETTE_ADD("cassette") |
| 32 | MCFG_CASSETTE_DEFAULT_STATE(CASSETTE_STOPPED) |
| 33 | MCFG_CASSETTE_INTERFACE("atari8bit_cass") |
| 34 | MACHINE_CONFIG_END |
| 35 | |
| 36 | machine_config_constructor a8sio_cassette_device::device_mconfig_additions() const |
| 37 | { |
| 38 | return MACHINE_CONFIG_NAME( cassette ); |
| 39 | } |
| 40 | |
| 41 | //************************************************************************** |
| 42 | // LIVE DEVICE |
| 43 | //************************************************************************** |
| 44 | |
| 45 | a8sio_cassette_device::a8sio_cassette_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 46 | : device_t(mconfig, A8SIO_CASSETTE, "Atari 8 bit cassette", tag, owner, clock, "a8sio_cass", __FILE__) |
| 47 | , device_a8sio_card_interface(mconfig, *this) |
| 48 | , m_cassette(*this, "cassette") |
| 49 | { |
| 50 | } |
| 51 | |
| 52 | a8sio_cassette_device::a8sio_cassette_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) |
| 53 | : device_t(mconfig, type, name, tag, owner, clock, shortname, source) |
| 54 | , device_a8sio_card_interface(mconfig, *this) |
| 55 | , m_cassette(*this, "cassette") |
| 56 | { |
| 57 | } |
| 58 | |
| 59 | void a8sio_cassette_device::device_start() |
| 60 | { |
| 61 | set_a8sio_device(); |
| 62 | } |
| 63 | |
| 64 | void a8sio_cassette_device::device_reset() |
| 65 | { |
| 66 | } |
| 67 | |
| 68 | WRITE_LINE_MEMBER( a8sio_cassette_device::motor_w ) |
| 69 | { |
| 70 | //printf("a8sio_cassette::motor_w %d\n", state); |
| 71 | } |
| 72 | |
trunk/src/emu/bus/a8sio/cassette.h
| r0 | r242654 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Wilbert Pol |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | cassette.h - Atari 8 bit cassette player(s) |
| 6 | |
| 7 | |
| 8 | Known cassette players: |
| 9 | - Atari XC11 |
| 10 | - Atari XC12 (no SIO connection for an additional device) |
| 11 | |
| 12 | ***************************************************************************/ |
| 13 | |
| 14 | #pragma once |
| 15 | |
| 16 | #ifndef __A8SIO_CASSETTE_H_ |
| 17 | #define __A8SIO_CASSETTE_H_ |
| 18 | |
| 19 | |
| 20 | #include "a8sio.h" |
| 21 | #include "imagedev/cassette.h" |
| 22 | |
| 23 | |
| 24 | class a8sio_cassette_device |
| 25 | : public device_t |
| 26 | , public device_a8sio_card_interface |
| 27 | { |
| 28 | public: |
| 29 | // construction/destruction |
| 30 | a8sio_cassette_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 31 | a8sio_cassette_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); |
| 32 | |
| 33 | // optional information overrides |
| 34 | virtual machine_config_constructor device_mconfig_additions() const; |
| 35 | |
| 36 | virtual DECLARE_WRITE_LINE_MEMBER( motor_w ); |
| 37 | |
| 38 | protected: |
| 39 | virtual void device_start(); |
| 40 | virtual void device_reset(); |
| 41 | |
| 42 | required_device<cassette_image_device> m_cassette; |
| 43 | }; |
| 44 | |
| 45 | // device type definition |
| 46 | extern const device_type A8SIO_CASSETTE; |
| 47 | |
| 48 | |
| 49 | #endif |