1 // license:BSD-3-Clause
2 // copyright-holders:R. Belmont
3 /***************************************************************************
4 
5   a2eauxslot.c - Apple IIe auxiliary slot and card emulation
6 
7   by R. Belmont
8 
9 ***************************************************************************/
10 
11 #include "emu.h"
12 #include "a2eauxslot.h"
13 
14 
15 //**************************************************************************
16 //  GLOBAL VARIABLES
17 //**************************************************************************
18 
19 DEFINE_DEVICE_TYPE(A2EAUXSLOT_SLOT, a2eauxslot_slot_device, "a2eauxslot_slot", "Apple IIe AUX Slot")
20 
21 //**************************************************************************
22 //  LIVE DEVICE
23 //**************************************************************************
24 
25 //-------------------------------------------------
26 //  a2eauxslot_slot_device - constructor
27 //-------------------------------------------------
a2eauxslot_slot_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)28 a2eauxslot_slot_device::a2eauxslot_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
29 	: a2eauxslot_slot_device(mconfig, A2EAUXSLOT_SLOT, tag, owner, clock)
30 {
31 }
32 
a2eauxslot_slot_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint32_t clock)33 a2eauxslot_slot_device::a2eauxslot_slot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
34 	: device_t(mconfig, type, tag, owner, clock)
35 	, device_single_card_slot_interface<device_a2eauxslot_card_interface>(mconfig, *this)
36 	, m_a2eauxslot(*this, finder_base::DUMMY_TAG)
37 {
38 }
39 
device_resolve_objects()40 void a2eauxslot_slot_device::device_resolve_objects()
41 {
42 	device_a2eauxslot_card_interface *const dev = get_card_device();
43 	if (dev)
44 		dev->set_a2eauxslot_device(m_a2eauxslot.target());
45 }
46 
47 //**************************************************************************
48 //  GLOBAL VARIABLES
49 //**************************************************************************
50 
51 DEFINE_DEVICE_TYPE(A2EAUXSLOT, a2eauxslot_device, "a2eauxslot", "Apple IIe AUX Bus")
52 
53 //**************************************************************************
54 //  LIVE DEVICE
55 //**************************************************************************
56 
57 //-------------------------------------------------
58 //  a2eauxslot_device - constructor
59 //-------------------------------------------------
60 
a2eauxslot_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock)61 a2eauxslot_device::a2eauxslot_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
62 	: a2eauxslot_device(mconfig, A2EAUXSLOT, tag, owner, clock)
63 {
64 }
65 
a2eauxslot_device(const machine_config & mconfig,device_type type,const char * tag,device_t * owner,uint32_t clock)66 a2eauxslot_device::a2eauxslot_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
67 	: device_t(mconfig, type, tag, owner, clock)
68 	, m_space(*this, finder_base::DUMMY_TAG, -1)
69 	, m_out_irq_cb(*this)
70 	, m_out_nmi_cb(*this)
71 	, m_device(nullptr)
72 {
73 }
74 
75 //-------------------------------------------------
76 //  device_resolve_objects - resolve objects that
77 //  may be needed for other devices to set
78 //  initial conditions at start time
79 //-------------------------------------------------
80 
device_resolve_objects()81 void a2eauxslot_device::device_resolve_objects()
82 {
83 	// resolve callbacks
84 	m_out_irq_cb.resolve_safe();
85 	m_out_nmi_cb.resolve_safe();
86 }
87 
88 //-------------------------------------------------
89 //  device_start - device-specific startup
90 //-------------------------------------------------
91 
device_start()92 void a2eauxslot_device::device_start()
93 {
94 }
95 
get_a2eauxslot_card()96 device_a2eauxslot_card_interface *a2eauxslot_device::get_a2eauxslot_card()
97 {
98 	return m_device;
99 }
100 
add_a2eauxslot_card(device_a2eauxslot_card_interface * card)101 void a2eauxslot_device::add_a2eauxslot_card(device_a2eauxslot_card_interface *card)
102 {
103 	m_device = card;
104 }
105 
set_irq_line(int state)106 void a2eauxslot_device::set_irq_line(int state)
107 {
108 	m_out_irq_cb(state);
109 }
110 
set_nmi_line(int state)111 void a2eauxslot_device::set_nmi_line(int state)
112 {
113 	m_out_nmi_cb(state);
114 }
115 
116 // interrupt request from a2eauxslot card
WRITE_LINE_MEMBER(a2eauxslot_device::irq_w)117 WRITE_LINE_MEMBER( a2eauxslot_device::irq_w ) { m_out_irq_cb(state); }
WRITE_LINE_MEMBER(a2eauxslot_device::nmi_w)118 WRITE_LINE_MEMBER( a2eauxslot_device::nmi_w ) { m_out_nmi_cb(state); }
119 
120 //**************************************************************************
121 //  DEVICE CONFIG A2EAUXSLOT CARD INTERFACE
122 //**************************************************************************
123 
124 
125 //**************************************************************************
126 //  DEVICE A2EAUXSLOT CARD INTERFACE
127 //**************************************************************************
128 
129 //-------------------------------------------------
130 //  device_a2eauxslot_card_interface - constructor
131 //-------------------------------------------------
132 
device_a2eauxslot_card_interface(const machine_config & mconfig,device_t & device)133 device_a2eauxslot_card_interface::device_a2eauxslot_card_interface(const machine_config &mconfig, device_t &device)
134 	: device_interface(device, "a2eaux"),
135 		m_a2eauxslot(nullptr),
136 		m_slot(0), m_next(nullptr)
137 {
138 }
139 
140 
141 //-------------------------------------------------
142 //  ~device_a2eauxslot_card_interface - destructor
143 //-------------------------------------------------
144 
~device_a2eauxslot_card_interface()145 device_a2eauxslot_card_interface::~device_a2eauxslot_card_interface()
146 {
147 }
148 
set_a2eauxslot_device(a2eauxslot_device * a2eauxslot)149 void device_a2eauxslot_card_interface::set_a2eauxslot_device(a2eauxslot_device *a2eauxslot)
150 {
151 	m_a2eauxslot = a2eauxslot;
152 	m_a2eauxslot->add_a2eauxslot_card(this);
153 }
154