summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/qbus/qbus.cpp
blob: 602f2cac685ec1d28565432fe1c05c5565431d3a (plain) (blame)
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
171
172
173
174
175
176
177
178
179
180
// license:BSD-3-Clause
// copyright-holders:Sergey Svishchev
/**********************************************************************

    DEC Q-Bus emulation (skeleton)

**********************************************************************/

#include "emu.h"

#include "qbus.h"

// Peripheral boards
#include "pc11.h"
#include "qtx.h"


void qbus_cards(device_slot_interface &device)
{
	device.option_add("pc11", DEC_PC11); /* Paper tape reader and punch */
	device.option_add("qts1", TTI_QTS1);
}


//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(QBUS, qbus_device, "qbus", "QBUS bus")
DEFINE_DEVICE_TYPE(QBUS_SLOT, qbus_slot_device, "qbus_slot", "QBUS slot")


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  device_qbus_card_interface - constructor
//-------------------------------------------------

device_qbus_card_interface::device_qbus_card_interface(const machine_config &mconfig, device_t &device) :
	device_interface(device, "qbus"),
	m_bus(nullptr),
	m_next(nullptr)
{
}


//-------------------------------------------------
//  qbus_slot_device - constructor
//-------------------------------------------------
qbus_slot_device::qbus_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, QBUS_SLOT, tag, owner, clock),
	device_slot_interface(mconfig, *this),
	m_write_birq4(*this),
	m_write_birq5(*this),
	m_write_birq6(*this),
	m_write_birq7(*this),
	m_write_bdmr(*this),
	m_bus(*this, DEVICE_SELF_OWNER)
{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void qbus_slot_device::device_start()
{
	device_qbus_card_interface *dev = dynamic_cast<device_qbus_card_interface *>(get_card_device());
	if (dev) m_bus->add_card(dev);

	m_write_birq4.resolve_safe();
	m_write_birq5.resolve_safe();
	m_write_birq6.resolve_safe();
	m_write_birq7.resolve_safe();
	m_write_bdmr.resolve_safe();
}


//-------------------------------------------------
//  qbus_device - constructor
//-------------------------------------------------

qbus_device::qbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, QBUS, tag, owner, clock),
	device_memory_interface(mconfig, *this),
	device_z80daisy_interface(mconfig, *this),
	m_program_config("QBUS A18", ENDIANNESS_BIG, 16, 16, 0, address_map_constructor()),
	m_out_birq4_cb(*this),
	m_out_birq5_cb(*this),
	m_out_birq6_cb(*this),
	m_out_birq7_cb(*this),
	m_out_bdmr_cb(*this)
{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void qbus_device::device_start()
{
	// resolve callbacks
	m_out_birq4_cb.resolve_safe();
	m_out_birq5_cb.resolve_safe();
	m_out_birq6_cb.resolve_safe();
	m_out_birq7_cb.resolve_safe();
	m_out_bdmr_cb.resolve_safe();

	m_maincpu = owner()->subdevice<cpu_device>(m_cputag);
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void qbus_device::device_reset()
{
}


//-------------------------------------------------
//  add_card - add card
//-------------------------------------------------

void qbus_device::add_card(device_qbus_card_interface *card)
{
	card->m_bus = this;
	m_device_list.append(*card);
}

void qbus_device::install_device(offs_t start, offs_t end, read16sm_delegate rhandler, write16sm_delegate whandler, uint32_t mask)
{
	m_maincpu->space(AS_PROGRAM).install_readwrite_handler(start, end, rhandler, whandler, mask);
}


//-------------------------------------------------
//  z80daisy_interface
//-------------------------------------------------

int qbus_device::z80daisy_irq_state()
{
	int data = 0;
	device_qbus_card_interface *entry = m_device_list.first();

	while (entry)
	{
		data = entry->z80daisy_irq_state();
		if (data)
			return data;
		entry = entry->next();
	}

	return data;
}

int qbus_device::z80daisy_irq_ack()
{
	int vec = -1;
	device_qbus_card_interface *entry = m_device_list.first();

	while (entry)
	{
		vec = entry->z80daisy_irq_ack();
		if (vec > 0)
			return vec;
		entry = entry->next();
	}

	return vec;
}

void qbus_device::z80daisy_irq_reti()
{
}