1 // license:BSD-3-Clause
2 // copyright-holders:Nathan Woods
3 /***************************************************************************
4
5 dgnalpha.c
6
7 Dragon Alpha
8
9 The Dragon Alpha was a prototype in development when Dragon Data went bust,
10 it is basically an enhanced Dragon 64, with built in modem, disk system, and
11 graphical boot rom.
12
13 It has the following extra hardware :-
14 A third 6821 PIA mapped between FF24 and FF27
15 An AY-8912, connected to the PIA.
16
17 Port A of the PIA is connected as follows :-
18
19 b0 BDIR of AY8912
20 b1 BC1 of AY8912
21 b2 Rom select, High= boot rom, low=BASIC rom
22 b3..7 not used.
23
24 Port B
25 b0..7 connected to D0..7 of the AY8912.
26
27 CB1 DRQ of WD2797.
28
29 /irqa
30 /irqb both connected to 6809 FIRQ.
31
32
33 The analog outputs of the AY-8912 are connected to the standard sound multiplexer.
34 The AY8912 output port is used as follows :-
35
36 b0..b3 /DS0../DS3 for the drive interface (through an inverter first).
37 b4 /motor for the drive interface (through an inverter first).
38 b5..b7 not used as far as I can tell.
39
40 A 6850 for the modem.
41
42 A WD2797, used as an internal disk interface, this is however connected in a slightly strange
43 way that I am yet to completely determine.
44 19/10/2004, WD2797 is mapped between FF2C and FF2F, however the order of the registers is
45 reversed so the command Register is at the highest address instead of the lowest. The Data
46 request pin is connected to CB1(pin 18) of PIA2, to cause an firq, the INTRQ, is connected via
47 an inverter to the 6809's NMI.
48
49 All these are as yet un-emulated.
50
51 29-Oct-2004, AY-8912 is now emulated.
52 30-Oct-2004, Internal disk interface now emulated, Normal DragonDos rom replaced with a re-assembled
53 version, that talks to the alpha hardware (verified on a clone of the real machine).
54
55 Dragon Alpha code added 21-Oct-2004,
56 Phill Harvey-Smith (afra@aurigae.demon.co.uk)
57
58 Added AY-8912 and FDC code 30-Oct-2004.
59
60 Fixed Dragon Alpha NMI enable/disable, following circuit traces on a real machine.
61 P.Harvey-Smith, 11-Aug-2005.
62
63 Re-implemented Alpha NMI enable/disable, using direct PIA reads, rather than
64 keeping track of it in a variable in the driver.
65 P.Harvey-Smith, 25-Sep-2006.
66
67 ***************************************************************************/
68
69 #include "emu.h"
70 #include "includes/dgnalpha.h"
71 #include "sound/ay8910.h"
72
73 //-------------------------------------------------
74 // device_start
75 //-------------------------------------------------
76
device_start(void)77 void dragon_alpha_state::device_start(void)
78 {
79 dragon64_state::device_start();
80 }
81
82
83
84 //-------------------------------------------------
85 // device_reset
86 //-------------------------------------------------
87
device_reset(void)88 void dragon_alpha_state::device_reset(void)
89 {
90 dragon64_state::device_reset();
91 }
92
93
94
95 /***************************************************************************
96 MODEM
97 ***************************************************************************/
98
99 //-------------------------------------------------
100 // modem_r
101 //-------------------------------------------------
102
modem_r(offs_t offset)103 uint8_t dragon_alpha_state::modem_r(offs_t offset)
104 {
105 return 0xFF;
106 }
107
108
109
110 //-------------------------------------------------
111 // modem_w
112 //-------------------------------------------------
113
modem_w(offs_t offset,uint8_t data)114 void dragon_alpha_state::modem_w(offs_t offset, uint8_t data)
115 {
116 }
117
118
119
120 /***************************************************************************
121 PIA2 ($FF24-$FF28) on Dragon Alpha/Professional
122
123 PIA2 PA0 bcdir to AY-8912
124 PIA2 PA1 bc0 to AY-8912
125 PIA2 PA2 Rom switch, 0=basic rom, 1=boot rom.
126 PIA2 PA3-PA7 Unknown/unused ?
127 PIA2 PB0-PB7 connected to D0..7 of the AY8912.
128 CB1 DRQ from WD2797 disk controller.
129 ***************************************************************************/
130
131 //-------------------------------------------------
132 // pia2_pa_w
133 //-------------------------------------------------
134
pia2_pa_w(uint8_t data)135 void dragon_alpha_state::pia2_pa_w(uint8_t data)
136 {
137 uint8_t ddr = ~m_pia_2->port_b_z_mask();
138
139 /* If bit 2 of the pia2 ddra is 1 then this pin is an output so use it */
140 /* to control the paging of the boot and basic roms */
141 /* Otherwise it set as an input, with an internal pull-up so it should */
142 /* always be high (enabling boot rom) */
143 /* PIA FIXME if (pia_get_ddr_a(2) & 0x04) */
144 if(ddr & 0x04)
145 {
146 page_rom(data & 0x04 ? true : false); /* bit 2 controls boot or basic rom */
147 }
148
149 /* Bits 0 and 1 for pia2 port a control the BCDIR and BC1 lines of the */
150 /* AY-8912 */
151 switch (data & 0x03)
152 {
153 case 0x00: /* Inactive, do nothing */
154 break;
155 case 0x01: /* Write to selected port */
156 m_ay8912->data_w(m_pia_2->b_output());
157 break;
158 case 0x02: /* Read from selected port */
159 m_pia_2->portb_w(m_ay8912->data_r());
160 break;
161 case 0x03: /* Select port to write to */
162 m_ay8912->address_w(m_pia_2->b_output());
163 break;
164 }
165 }
166
167
168
169 //-------------------------------------------------
170 // pia1_firq_a
171 //-------------------------------------------------
172
WRITE_LINE_MEMBER(dragon_alpha_state::pia2_firq_a)173 WRITE_LINE_MEMBER( dragon_alpha_state::pia2_firq_a )
174 {
175 recalculate_firq();
176 }
177
178
179
180 //-------------------------------------------------
181 // pia1_firq_b
182 //-------------------------------------------------
183
WRITE_LINE_MEMBER(dragon_alpha_state::pia2_firq_b)184 WRITE_LINE_MEMBER( dragon_alpha_state::pia2_firq_b )
185 {
186 recalculate_firq();
187 }
188
189
190
191 /***************************************************************************
192 CPU INTERRUPTS
193 ***************************************************************************/
194
195 //-------------------------------------------------
196 // firq_get_line - gets the value of the FIRQ line
197 // passed into the CPU
198 //-------------------------------------------------
199
firq_get_line(void)200 bool dragon_alpha_state::firq_get_line(void)
201 {
202 return dragon_state::firq_get_line() || m_pia_2->irq_a_state() || m_pia_2->irq_b_state();
203 }
204
205
206
207 /***************************************************************************
208 AY8912
209 ***************************************************************************/
210
211 //-------------------------------------------------
212 // psg_porta_read
213 //-------------------------------------------------
214
psg_porta_read()215 uint8_t dragon_alpha_state::psg_porta_read()
216 {
217 return 0;
218 }
219
220
221
222 //-------------------------------------------------
223 // psg_porta_read
224 //-------------------------------------------------
225
psg_porta_write(uint8_t data)226 void dragon_alpha_state::psg_porta_write(uint8_t data)
227 {
228 /* Bits 0..3 are the drive select lines for the internal floppy interface */
229 /* Bit 4 is the motor on, in the real hardware these are inverted on their way to the drive */
230 /* Bits 5,6,7 are connected to /DDEN, ENP and 5/8 on the WD2797 */
231
232 floppy_image_device *floppy = nullptr;
233
234 for (int n = 0; n < 4; n++)
235 if (BIT(data, n))
236 floppy = m_floppy[n]->get_device();
237
238 m_fdc->set_floppy(floppy);
239
240 // todo: turning the motor on with bit 4 isn't giving the drive enough
241 // time to spin up, how does it work in hardware?
242 for (auto &f : m_floppy)
243 if (f->get_device()) f->get_device()->mon_w(0);
244
245 m_fdc->dden_w(BIT(data, 5));
246 }
247
248 /***************************************************************************
249 FDC
250 ***************************************************************************/
251
252 //-------------------------------------------------
253 // fdc_intrq_w - The NMI line on the Alpha is gated
254 // through IC16 (early PLD), and is gated by pia2 CA2
255 //-------------------------------------------------
256
WRITE_LINE_MEMBER(dragon_alpha_state::fdc_intrq_w)257 WRITE_LINE_MEMBER( dragon_alpha_state::fdc_intrq_w )
258 {
259 if (state)
260 {
261 if (m_pia_2->ca2_output_z())
262 m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
263 }
264 else
265 {
266 m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
267 }
268 }
269
270
271
272 //-------------------------------------------------
273 // fdc_drq_w - The DRQ line goes through pia2 CB1,
274 // in exactly the same way as DRQ from DragonDos
275 // does for pia1 CB1
276 //-------------------------------------------------
277
WRITE_LINE_MEMBER(dragon_alpha_state::fdc_drq_w)278 WRITE_LINE_MEMBER( dragon_alpha_state::fdc_drq_w )
279 {
280 m_pia_2->cb1_w(state ? ASSERT_LINE : CLEAR_LINE);
281 }
282