1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************
Prism VTX 5000 Modem
**********************************************************************/
#include "emu.h"
#include "vtx5000.h"
#include "machine/clock.h"
#include "machine/i8251.h"
#include "bus/rs232/rs232.h"
namespace {
class spectrum_vtx5000_device : public device_t, public device_spectrum_expansion_interface
{
public:
spectrum_vtx5000_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, SPECTRUM_VTX5000, tag, owner, clock)
, device_spectrum_expansion_interface(mconfig, *this)
, m_exp(*this, "exp")
, m_usart(*this, "i8251")
, m_rom(*this, "rom")
{
}
protected:
virtual void device_start() override;
virtual void device_reset() override;
virtual void device_add_mconfig(machine_config &config) override;
virtual const tiny_rom_entry *device_rom_region() const override;
virtual uint8_t mreq_r(offs_t offset) override;
virtual uint8_t iorq_r(offs_t offset) override;
virtual void iorq_w(offs_t offset, uint8_t data) override;
virtual bool romcs() override;
// passthru
virtual void pre_opcode_fetch(offs_t offset) override { m_exp->pre_opcode_fetch(offset); }
virtual void post_opcode_fetch(offs_t offset) override { m_exp->post_opcode_fetch(offset); }
virtual void pre_data_fetch(offs_t offset) override { m_exp->pre_data_fetch(offset); }
virtual void post_data_fetch(offs_t offset) override { m_exp->post_data_fetch(offset); }
virtual void mreq_w(offs_t offset, uint8_t data) override { if (m_exp->romcs()) m_exp->mreq_w(offset, data); }
private:
required_device<spectrum_expansion_slot_device> m_exp;
required_device<i8251_device> m_usart;
required_memory_region m_rom;
bool m_romcs;
};
ROM_START(vtx5000)
ROM_REGION( 0x2000, "rom", 0 )
ROM_SYSTEM_BIOS(0, "v31mnet", "V3.1 Micronet")
ROMX_LOAD("vtx5000-3-1.rom", 0x0000, 0x2000, CRC(1431505c) SHA1(42ae2b47c44d8c0d6a6c6a2b39a4a25a6d3a4bda), ROM_BIOS(0))
ROM_SYSTEM_BIOS(1, "v31hlink", "V3.1 Homelink")
ROMX_LOAD("homelink.rom", 0x0000, 0x2000, CRC(527d7f32) SHA1(4490186845b198ca9191dd711bd38274cba6f04b), ROM_BIOS(1))
ROM_END
const tiny_rom_entry *spectrum_vtx5000_device::device_rom_region() const
{
return ROM_NAME(vtx5000);
}
//-------------------------------------------------
// device_add_mconfig - add device configuration
//-------------------------------------------------
void spectrum_vtx5000_device::device_add_mconfig(machine_config &config)
{
I8251(config, m_usart, 2.4576_MHz_XTAL);
m_usart->txd_handler().set("modem", FUNC(rs232_port_device::write_txd));
m_usart->dtr_handler().set("modem", FUNC(rs232_port_device::write_dtr));
m_usart->rts_handler().set([this](int state) { m_romcs = state; });
clock_device &rx_clock(CLOCK(config, "rx_clock", 2.4576_MHz_XTAL / 16 / 2)); // 1200 baud
rx_clock.signal_handler().set(m_usart, FUNC(i8251_device::write_rxc));
clock_device &tx_clock(CLOCK(config, "tx_clock", 2.4576_MHz_XTAL / 16 / 32)); // 75 baud
tx_clock.signal_handler().set(m_usart, FUNC(i8251_device::write_txc));
rs232_port_device &rs232(RS232_PORT(config, "modem", default_rs232_devices, nullptr)); // TCM3101 (internal modem)
rs232.rxd_handler().set(m_usart, FUNC(i8251_device::write_rxd));
rs232.dcd_handler().set(m_usart, FUNC(i8251_device::write_dsr)).invert();
// passthru
SPECTRUM_EXPANSION_SLOT(config, m_exp, spectrum_expansion_devices, nullptr);
m_exp->irq_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::irq_w));
m_exp->nmi_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::nmi_w));
m_exp->fb_r_handler().set(DEVICE_SELF_OWNER, FUNC(spectrum_expansion_slot_device::fb_r));
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void spectrum_vtx5000_device::device_start()
{
// CTS grounded
m_usart->write_cts(0);
save_item(NAME(m_romcs));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void spectrum_vtx5000_device::device_reset()
{
m_romcs = 1;
}
//**************************************************************************
// IMPLEMENTATION
//**************************************************************************
bool spectrum_vtx5000_device::romcs()
{
return m_romcs || m_exp->romcs();
}
uint8_t spectrum_vtx5000_device::mreq_r(offs_t offset)
{
uint8_t data = 0xff;
if (m_romcs)
data = m_rom->base()[offset & 0x1fff];
if (m_exp->romcs())
data &= m_exp->mreq_r(offset);
return data;
}
uint8_t spectrum_vtx5000_device::iorq_r(offs_t offset)
{
uint8_t data = m_exp->iorq_r(offset);
if ((offset & 0x7f) == 0x7f)
data = m_usart->read(BIT(offset, 7));
return data;
}
void spectrum_vtx5000_device::iorq_w(offs_t offset, uint8_t data)
{
if ((offset & 0x7f) == 0x7f)
m_usart->write(BIT(offset, 7), data);
m_exp->iorq_w(offset, data);
}
} // anonymous namespace
DEFINE_DEVICE_TYPE_PRIVATE(SPECTRUM_VTX5000, device_spectrum_expansion_interface, spectrum_vtx5000_device, "spectrum_vtx5000", "Prism VTX 5000 Modem")
|