summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/c64/tdos.cpp
blob: a814ccc26a8a5fe66c99b8f8e788aa7d3d30cad4 (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
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************

    Triton QD TDOS cartridge emulation

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

/*

PCB Layout
----------

XM-2206-A (top)
XM-2205-A (bottom)

            |===========================|
            |            CN4            |
            |                           |
            |      ULA                  |
            |                           |
            |      6.5MHz               |
            |                           |
            |      SSDA                 |
            |                 LS175     |
            |                 LS367     |
            |            CN3            |
            |=========|||||||||=========|
                      |||||||||
        |=============|||||||||============|
        |                CN2               |
        |       LS00     LS02     LS138    |
|=======|                                  |
|=|             LS245        ROM           |
|=|                                        |
|=|                                        |
|=|                                     CN1|
|=|                                        |
|=|                                        |
|=|                                        |
|=|                             SW1        |
|==========================================|

ROM    - Hitachi HN482764G 8Kx8 EPROM "TDOS 1.2"
ULA    - Ferranti ULA5RB073E1 XZ-2085-1 40-pin custom ULA
SSDA   - Motorola MC68A52P SSDA
CN1    - C64 expansion connector (pass-thru)
CN2,3  - 18x1 flat ribbon cable to other PCB
CN4    - 9 wire cable to Mitsumi Quick Disk 3" drive
SW1    - cartridge on/off switch


Flat ribbon cable pinout
------------------------
1   D7
2   D6
3   D5
4   D4
5   D3
6   LS00 4Y -> LS367 _G1
7   phi2
8   LS00 3Y -> LS175 CP
9   D2
10  D1
11  D0
12  RESET
13  A0
14  R/_W
15  GND
16  +5V
17  LS138 O2 -> LS367 _G1
18  LS138 O0 -> SSDA _CS


Drive cable pinout
------------------
1   WP      Write Protected
2   WD      Write Data
3   WG      Write Gate
4   MO      Motor
5   RD      Read Data
6   RY      Ready
7   MS      Media Set
8   RS      Reset
9   +5V
10  GND


ULA pinout
----------
            _____   _____
         1 |*    \_/     | 40
         2 |             | 39
         3 |             | 38
         4 |             | 37
         5 |             | 36  GND
         6 |             | 35
    RD   7 |             | 34
   _D5   8 |             | 33
   RxC   9 |             | 32
   RxD  10 |  XZ-2085-1  | 31
        11 |             | 30
    WD  12 |             | 29
   TxC  13 |             | 28
   TxD  14 |             | 27
    D7  15 |             | 26
    WG  16 |             | 25  +5V
        17 |             | 24  XTAL2
        18 |             | 23  XTAL1
    RS  19 |             | 22  GND
        20 |_____________| 21


BASIC commands (SYS 32768 to activate)
--------------------------------------
@Dn
@Format
@Dir
@Save
@ASave
@Write
@Load
@Run
@Aload
@Kill
@Quit
@ACopy
@CassCopy

*/

#include "emu.h"
#include "tdos.h"



//**************************************************************************
//  MACROS/CONSTANTS
//**************************************************************************

#define MC68A52P_TAG        "mc6852"



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

DEFINE_DEVICE_TYPE(C64_TDOS, c64_tdos_cartridge_device, "c64_tdos", "C64 TDOS cartridge")


//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------

void c64_tdos_cartridge_device::device_add_mconfig(machine_config &config)
{
	MC6852(config, m_ssda, XTAL(6'500'000));

	C64_EXPANSION_SLOT(config, m_exp, DERIVED_CLOCK(1, 1), c64_expansion_cards, nullptr);
	m_exp->set_passthrough();
}


//-------------------------------------------------
//  INPUT_PORTS( c64_tdos )
//-------------------------------------------------

static INPUT_PORTS_START( c64_tdos )
	PORT_START("SW1")
	PORT_DIPNAME( 0x01, 0x01, "Enabled" )
	PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
	PORT_DIPSETTING(    0x01, DEF_STR( On ) )
INPUT_PORTS_END


//-------------------------------------------------
//  input_ports - device-specific input ports
//-------------------------------------------------

ioport_constructor c64_tdos_cartridge_device::device_input_ports() const
{
	return INPUT_PORTS_NAME( c64_tdos );
}



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

//-------------------------------------------------
//  c64_tdos_cartridge_device - constructor
//-------------------------------------------------

c64_tdos_cartridge_device::c64_tdos_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, C64_TDOS, tag, owner, clock),
	device_c64_expansion_card_interface(mconfig, *this),
	m_ssda(*this, MC68A52P_TAG),
	m_exp(*this, "exp"),
	m_sw1(*this, "SW1"), m_enabled(false)
{
}


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

void c64_tdos_cartridge_device::device_start()
{
}


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

void c64_tdos_cartridge_device::device_reset()
{
	m_ssda->reset();
	//m_ula->reset();
	//flip-flop reset

	m_enabled = m_sw1->read();
}


//-------------------------------------------------
//  c64_cd_r - cartridge data read
//-------------------------------------------------

uint8_t c64_tdos_cartridge_device::c64_cd_r(address_space &space, offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
{
	data = m_exp->cd_r(space, offset, data, sphi2, ba, roml, romh, io1, io2);

	if (m_enabled && !roml)
	{
		data = m_roml[offset & 0x1fff];
	}

	if (m_enabled && !io2 && sphi2)
	{
		switch ((offset >> 1) & 0x7f)
		{
		case 0:
			data = m_ssda->read(space, offset & 0x01);
			break;

		case 1:
			break;

		case 2:
			/*

			    bit     description

			    0
			    1
			    2
			    3
			    4
			    5       drive MS
			    6       drive WP
			    7       drive RY

			*/
			break;
		}
	}

	return data;
}


//-------------------------------------------------
//  c64_cd_w - cartridge data write
//-------------------------------------------------

void c64_tdos_cartridge_device::c64_cd_w(address_space &space, offs_t offset, uint8_t data, int sphi2, int ba, int roml, int romh, int io1, int io2)
{
	m_exp->cd_w(space, offset, data, sphi2, ba, roml, romh, io1, io2);

	if (m_enabled && !io2 && sphi2)
	{
		switch ((offset >> 1) & 0x7f)
		{
		case 0:
			m_ssda->write(space, offset & 0x01, data);
			break;

		case 1:
			/*

			    bit     description

			    0
			    1
			    2
			    3
			    4
			    5       ULA pin 8, inverted
			    6       drive MO
			    7       ULA pin 15

			*/
			break;

		case 2:
			break;
		}
	}
}


//-------------------------------------------------
//  c64_game_r - GAME read
//-------------------------------------------------

int c64_tdos_cartridge_device::c64_game_r(offs_t offset, int sphi2, int ba, int rw)
{
	return m_enabled ? 1 : m_exp->game_r(offset, sphi2, ba, rw, m_slot->hiram());
}


//-------------------------------------------------
//  c64_exrom_r - EXROM read
//-------------------------------------------------

int c64_tdos_cartridge_device::c64_exrom_r(offs_t offset, int sphi2, int ba, int rw)
{
	return m_enabled ? 0 : m_exp->exrom_r(offset, sphi2, ba, rw, m_slot->hiram());
}