|
| 1 | +// license:LGPL-2.1+ |
| 2 | +// copyright-holders:Michael Zapf |
| 3 | +/**************************************************************************** |
| 4 | + I/O port splitter |
| 5 | +
|
| 6 | + The I/O port splitter connects to the TI-99/4(A) console at its I/O port |
| 7 | + and provides two I/O ports. That way, two Peripheral Expansion boxes or |
| 8 | + one PEB and a sidecar chain may be connected. |
| 9 | +
|
| 10 | + | Port 2 |
| 11 | + v |
| 12 | + +---+ |
| 13 | + +----------------+ | | |
| 14 | + | TI-99/4(A) |---+ +--+ |
| 15 | + +------------+---+ Splitter | <-- Port 1 |
| 16 | + | oooooooooo | |----------+ |
| 17 | + | oooooooooo | | |
| 18 | + +----------------- |
| 19 | +
|
| 20 | + The splitter was designed 2015 by Jim Fetzner (as Tekumel Software) |
| 21 | +
|
| 22 | + March 2025, Michael Zapf |
| 23 | +
|
| 24 | +*****************************************************************************/ |
| 25 | + |
| 26 | +#include "emu.h" |
| 27 | +#include "ioport.h" |
| 28 | +#include "splitter.h" |
| 29 | +#include "bus/ti99/peb/peribox.h" |
| 30 | + |
| 31 | +#define LOG_WARN (1U << 1) // Warnings |
| 32 | +#define LOG_CONFIG (1U << 2) // Configuration |
| 33 | +#define LOG_INT (1U << 3) |
| 34 | +#define LOG_READY (1U << 4) |
| 35 | + |
| 36 | +// #define VERBOSE (LOG_CONFIG | LOG_WARN) |
| 37 | + |
| 38 | +#include "logmacro.h" |
| 39 | + |
| 40 | +DEFINE_DEVICE_TYPE(TI99_IOSPLIT, bus::ti99::internal::ioport_splitter_device, "ti99_iosplit", "TI-99 I/O Port Splitter") |
| 41 | + |
| 42 | +namespace bus::ti99::internal { |
| 43 | + |
| 44 | +#define PORT1 "port1" |
| 45 | +#define PORT2 "port2" |
| 46 | + |
| 47 | +ioport_splitter_device::ioport_splitter_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) |
| 48 | + : ioport_attached_device(mconfig, type, tag, owner, clock), |
| 49 | + m_port1(*this, PORT1), |
| 50 | + m_port2(*this, PORT2) |
| 51 | +{ |
| 52 | +} |
| 53 | + |
| 54 | +ioport_splitter_device::ioport_splitter_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) |
| 55 | + : ioport_splitter_device(mconfig, TI99_IOSPLIT, tag, owner, clock) |
| 56 | +{ |
| 57 | +} |
| 58 | + |
| 59 | +void ioport_splitter_device::readz(offs_t offset, uint8_t *value) |
| 60 | +{ |
| 61 | + // With a proper configuration, only one device on one of the branches |
| 62 | + // will respond. |
| 63 | + if (m_port1 != nullptr) |
| 64 | + m_port1->readz(offset, value); |
| 65 | + |
| 66 | + if (m_port2 != nullptr) |
| 67 | + m_port2->readz(offset, value); |
| 68 | +} |
| 69 | + |
| 70 | +void ioport_splitter_device::write(offs_t offset, uint8_t data) |
| 71 | +{ |
| 72 | + if (m_port1 != nullptr) |
| 73 | + m_port1->write(offset, data); |
| 74 | + |
| 75 | + if (m_port2 != nullptr) |
| 76 | + m_port2->write(offset, data); |
| 77 | +} |
| 78 | + |
| 79 | +void ioport_splitter_device::setaddress_dbin(offs_t offset, int state) |
| 80 | +{ |
| 81 | + if (m_port1 != nullptr) |
| 82 | + m_port1->setaddress_dbin(offset, state); |
| 83 | + |
| 84 | + if (m_port2 != nullptr) |
| 85 | + m_port2->setaddress_dbin(offset, state); |
| 86 | +} |
| 87 | + |
| 88 | +void ioport_splitter_device::crureadz(offs_t offset, uint8_t *value) |
| 89 | +{ |
| 90 | + if (m_port1 != nullptr) |
| 91 | + m_port1->crureadz(offset, value); |
| 92 | + |
| 93 | + if (m_port2 != nullptr) |
| 94 | + m_port2->crureadz(offset, value); |
| 95 | +} |
| 96 | + |
| 97 | +void ioport_splitter_device::cruwrite(offs_t offset, uint8_t data) |
| 98 | +{ |
| 99 | + if (m_port1 != nullptr) |
| 100 | + m_port1->cruwrite(offset, data); |
| 101 | + |
| 102 | + if (m_port2 != nullptr) |
| 103 | + m_port2->cruwrite(offset, data); |
| 104 | +} |
| 105 | + |
| 106 | +void ioport_splitter_device::memen_in(int state) |
| 107 | +{ |
| 108 | + if (m_port1 != nullptr) |
| 109 | + m_port1->memen_in(state); |
| 110 | + |
| 111 | + if (m_port2 != nullptr) |
| 112 | + m_port2->memen_in(state); |
| 113 | +} |
| 114 | + |
| 115 | +void ioport_splitter_device::msast_in(int state) |
| 116 | +{ |
| 117 | + if (m_port1 != nullptr) |
| 118 | + m_port1->msast_in(state); |
| 119 | + |
| 120 | + if (m_port2 != nullptr) |
| 121 | + m_port2->msast_in(state); |
| 122 | +} |
| 123 | + |
| 124 | +void ioport_splitter_device::clock_in(int state) |
| 125 | +{ |
| 126 | + if (m_port1 != nullptr) |
| 127 | + m_port1->clock_in(state); |
| 128 | + |
| 129 | + if (m_port2 != nullptr) |
| 130 | + m_port2->clock_in(state); |
| 131 | +} |
| 132 | + |
| 133 | +void ioport_splitter_device::reset_in(int state) |
| 134 | +{ |
| 135 | + if (m_port1 != nullptr) |
| 136 | + m_port1->reset_in(state); |
| 137 | + |
| 138 | + if (m_port2 != nullptr) |
| 139 | + m_port2->reset_in(state); |
| 140 | +} |
| 141 | + |
| 142 | +template<int port> |
| 143 | +void ioport_splitter_device::extint(int state) |
| 144 | +{ |
| 145 | + LOGMASKED(LOG_INT, "propagating INTA from port %d to console: %d\n", port, state); |
| 146 | + if (state==ASSERT_LINE) |
| 147 | + m_inta_flag |= port; // 1 or 2 |
| 148 | + else |
| 149 | + m_inta_flag &= ~port; // 1 or 2 |
| 150 | + |
| 151 | + set_extint((m_inta_flag != 0)? ASSERT_LINE : CLEAR_LINE); |
| 152 | +} |
| 153 | + |
| 154 | +template<int port> |
| 155 | +void ioport_splitter_device::ready(int state) |
| 156 | +{ |
| 157 | + LOGMASKED(LOG_READY, "Incoming READY=%d from port %d\n", state, port); |
| 158 | + // We store the inverse state |
| 159 | + if (state==CLEAR_LINE) |
| 160 | + m_ready_flag |= port; // 1 or 2 |
| 161 | + else |
| 162 | + m_ready_flag &= ~port; // 1 or 2 |
| 163 | + |
| 164 | + set_ready((m_ready_flag != 0)? CLEAR_LINE : ASSERT_LINE); |
| 165 | +} |
| 166 | + |
| 167 | +void ioport_splitter_device::device_start() |
| 168 | +{ |
| 169 | + LOG("Starting I/O Port Splitter\n"); |
| 170 | +} |
| 171 | + |
| 172 | + |
| 173 | +void ioport_splitter_device::device_config_complete() |
| 174 | +{ |
| 175 | + m_inta_flag = 0; |
| 176 | + m_ready_flag = 0; |
| 177 | +} |
| 178 | + |
| 179 | +void ioport_splitter_device::device_add_mconfig(machine_config &config) |
| 180 | +{ |
| 181 | + TI99_IOPORT(config, m_port1, 1, ti99_ioport_options_evpc1, nullptr); |
| 182 | + TI99_IOPORT(config, m_port2, 2, ti99_ioport_options_evpc1, nullptr); |
| 183 | + |
| 184 | + m_port1->extint_cb().set(FUNC(ioport_splitter_device::extint<1>)); |
| 185 | + m_port2->extint_cb().set(FUNC(ioport_splitter_device::extint<2>)); |
| 186 | + m_port1->ready_cb().set(FUNC(ioport_splitter_device::ready<1>)); |
| 187 | + m_port2->ready_cb().set(FUNC(ioport_splitter_device::ready<2>)); |
| 188 | +} |
| 189 | + |
| 190 | +} // end namespace bus::ti99::internal |
0 commit comments