summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/dgnalpha.c
blob: 8ec09a26daf00aedfd0f3535f7726a97525b3ac3 (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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
/***************************************************************************

    dgnalpha.c

    Dragon Alpha

    The Dragon Alpha was a prototype in development when Dragon Data went bust,
    it is basically an enhanced Dragon 64, with built in modem, disk system, and
    graphical boot rom.

    It has the following extra hardware :-
    A third 6821 PIA mapped between FF24 and FF27
        An AY-8912, connected to the PIA.

    Port A of the PIA is connected as follows :-

        b0  BDIR of AY8912
        b1  BC1 of AY8912
        b2  Rom select, High= boot rom, low=BASIC rom
        b3..7 not used.

    Port B
        b0..7 connected to D0..7 of the AY8912.

    CB1 DRQ of WD2797.

    /irqa
    /irqb   both connected to 6809 FIRQ.


    The analog outputs of the AY-8912 are connected to the standard sound multiplexer.
    The AY8912 output port is used as follows :-

        b0..b3  /DS0../DS3 for the drive interface (through an inverter first).
        b4      /motor for the drive interface (through an inverter first).
        b5..b7  not used as far as I can tell.

    A 6850 for the modem.

    A WD2797, used as an internal disk interface, this is however connected in a slightly strange
    way that I am yet to completely determine.
    19/10/2004, WD2797 is mapped between FF2C and FF2F, however the order of the registers is
    reversed so the command Register is at the highest address instead of the lowest. The Data
    request pin is connected to CB1(pin 18) of PIA2, to cause an firq, the INTRQ, is connected via
    an inverter to the 6809's NMI.

    All these are as yet un-emulated.

    29-Oct-2004, AY-8912 is now emulated.
    30-Oct-2004, Internal disk interface now emulated, Normal DragonDos rom replaced with a re-assembled
                version, that talks to the alpha hardware (verified on a clone of the real machine).

Dragon Alpha code added 21-Oct-2004,
            Phill Harvey-Smith (afra@aurigae.demon.co.uk)

            Added AY-8912 and FDC code 30-Oct-2004.

Fixed Dragon Alpha NMI enable/disable, following circuit traces on a real machine.
    P.Harvey-Smith, 11-Aug-2005.

Re-implemented Alpha NMI enable/disable, using direct PIA reads, rather than
keeping track of it in a variable in the driver.
    P.Harvey-Smith, 25-Sep-2006.

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

#include "includes/dgnalpha.h"
#include "sound/ay8910.h"
#include "imagedev/flopdrv.h"

//-------------------------------------------------
//  device_start
//-------------------------------------------------

void dragon_alpha_state::device_start(void)
{
	dragon_state::device_start();
	save_item(NAME(m_just_reset));
}



//-------------------------------------------------
//  device_reset
//-------------------------------------------------

void dragon_alpha_state::device_reset(void)
{
	dragon_state::device_reset();
	m_just_reset = 1;
}



/***************************************************************************
  MODEM
***************************************************************************/

//-------------------------------------------------
//  modem_r
//-------------------------------------------------

UINT8 dragon_alpha_state::modem_r(offs_t offset)
{
	return 0xFF;
}



//-------------------------------------------------
//  modem_w
//-------------------------------------------------

void dragon_alpha_state::modem_w(offs_t offset, UINT8 data)
{
}



/***************************************************************************
  PIA1
***************************************************************************/

//-------------------------------------------------
//  ff20_read
//-------------------------------------------------

READ8_MEMBER( dragon_alpha_state::ff20_read )
{
	UINT8 result = 0x00;

	switch(offset & 0x0f)
	{
		case 0: case 1: case 2: case 3:
			result = dragon_state::ff20_read(space, offset, mem_mask);
			break;

		case 4: case 5: case 6: case 7:
			result = m_pia_2->read(space, offset, mem_mask);
			break;

		case 8: case 9: case 10: case 11:
			result = modem_r(offset);
			break;

		case 12:
			result = m_fdc->data_r(space, 0);
			break;

		case 13:
			result = m_fdc->sector_r(space, 0);
			break;

		case 14:
			result = m_fdc->track_r(space, 0);
			break;

		case 15:
			result = m_fdc->status_r(space, 0);
			break;
	}
	return result;
}



//-------------------------------------------------
//  ff20_write
//-------------------------------------------------

WRITE8_MEMBER( dragon_alpha_state::ff20_write )
{
	switch(offset & 0x0f)
	{
		case 0: case 1: case 2: case 3:
			dragon_state::ff20_write(space, offset, data, mem_mask);
			break;

		case 4: case 5: case 6: case 7:
			m_pia_2->write(space, offset, data, mem_mask);
			break;

		case 8: case 9: case 10: case 11:
			modem_w(offset, data);
			break;

		case 12:
			m_fdc->data_w(space, 0, data);
			break;
		case 13:
			m_fdc->sector_w(space, 0, data);
			break;
		case 14:
			m_fdc->track_w(space, 0, data);
			break;
		case 15:
			m_fdc->command_w(space, 0, data);

			/* disk head is encoded in the command byte */
			m_fdc->set_side((data & 0x02) ? 1 : 0);
			break;
	}
}


/***************************************************************************
  PIA2 ($FF24-$FF28) on Dragon Alpha/Professional

    PIA2 PA0        bcdir to AY-8912
    PIA2 PA1        bc0 to AY-8912
    PIA2 PA2        Rom switch, 0=basic rom, 1=boot rom.
    PIA2 PA3-PA7    Unknown/unused ?
    PIA2 PB0-PB7    connected to D0..7 of the AY8912.
    CB1             DRQ from WD2797 disk controler.
***************************************************************************/

//-------------------------------------------------
//  pia2_pa_w
//-------------------------------------------------

WRITE8_MEMBER( dragon_alpha_state::pia2_pa_w )
{
	UINT8 ddr = ~m_pia_2->port_b_z_mask();

	/* If bit 2 of the pia2 ddra is 1 then this pin is an output so use it */
	/* to control the paging of the boot and basic roms */
	/* Otherwise it set as an input, with an internal pull-up so it should */
	/* always be high (enabling boot rom) */
	/* PIA FIXME if (pia_get_ddr_a(2) & 0x04) */
	if(ddr & 0x04)
	{
		page_rom(data & 0x04 ? true : false);   /* bit 2 controls boot or basic rom */
	}

	/* Bits 0 and 1 for pia2 port a control the BCDIR and BC1 lines of the */
	/* AY-8912 */
	switch (data & 0x03)
	{
		case 0x00:      /* Inactive, do nothing */
			break;
		case 0x01:      /* Write to selected port */
			m_ay8912->data_w(space, 0, m_pia_2->b_output());
			break;
		case 0x02:      /* Read from selected port */
			m_pia_2->portb_w(m_ay8912->data_r(space, 0));
			break;
		case 0x03:      /* Select port to write to */
			m_ay8912->address_w(space, 0, m_pia_2->b_output());
			break;
	}
}



//-------------------------------------------------
//  pia1_firq_a
//-------------------------------------------------

WRITE_LINE_MEMBER( dragon_alpha_state::pia2_firq_a )
{
	recalculate_firq();
}



//-------------------------------------------------
//  pia1_firq_b
//-------------------------------------------------

WRITE_LINE_MEMBER( dragon_alpha_state::pia2_firq_b )
{
	recalculate_firq();
}



/***************************************************************************
  CPU INTERRUPTS
***************************************************************************/

//-------------------------------------------------
//  firq_get_line - gets the value of the FIRQ line
//  passed into the CPU
//-------------------------------------------------

bool dragon_alpha_state::firq_get_line(void)
{
	return dragon_state::firq_get_line() || m_pia_2->irq_a_state() || m_pia_2->irq_b_state();
}



/***************************************************************************
  AY8912
***************************************************************************/

//-------------------------------------------------
//  psg_porta_read
//-------------------------------------------------

READ8_MEMBER( dragon_alpha_state::psg_porta_read )
{
	return 0;
}



//-------------------------------------------------
//  psg_porta_read
//-------------------------------------------------

WRITE8_MEMBER( dragon_alpha_state::psg_porta_write )
{
	/* Bits 0..3 are the drive select lines for the internal floppy interface */
	/* Bit 4 is the motor on, in the real hardware these are inverted on their way to the drive */
	/* Bits 5,6,7 are connected to /DDEN, ENP and 5/8 on the WD2797 */
	switch (data & 0xF)
	{
		case(0x01) :
			m_fdc->set_drive(0);
			break;
		case(0x02) :
			m_fdc->set_drive(1);
			break;
		case(0x04) :
			m_fdc->set_drive(2);
			break;
		case(0x08) :
			m_fdc->set_drive(3);
			break;
	}
}

/***************************************************************************
  FDC
***************************************************************************/

//-------------------------------------------------
//  fdc_intrq_w - The NMI line on the Alpha is gated
//  through IC16 (early PLD), and is gated by pia2 CA2
//-------------------------------------------------

WRITE_LINE_MEMBER( dragon_alpha_state::fdc_intrq_w )
{
	if (state)
	{
		if (m_just_reset)
		{
			m_just_reset = 0;
		}
		else
		{
			if (m_pia_2->ca2_output_z())
				m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE);
		}
	}
	else
	{
		m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE);
	}
}



//-------------------------------------------------
//  fdc_drq_w - The DRQ line goes through pia2 CB1,
//  in exactly the same way as DRQ from DragonDos
//  does for pia1 CB1
//-------------------------------------------------

WRITE_LINE_MEMBER( dragon_alpha_state::fdc_drq_w )
{
	m_pia_2->cb1_w(state ? ASSERT_LINE : CLEAR_LINE);
}



//-------------------------------------------------
//  fdc_interface
//-------------------------------------------------

const wd17xx_interface dragon_alpha_state::fdc_interface =
{
	DEVCB_NULL,
	DEVCB_DRIVER_LINE_MEMBER(dragon_alpha_state, fdc_intrq_w),
	DEVCB_DRIVER_LINE_MEMBER(dragon_alpha_state, fdc_drq_w),
	{FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
};