summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/aquarius/qdisk.cpp
blob: ba06201f5549770e2a814c4e6703afcfe8b8e23f (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
// license:BSD-3-Clause
// copyright-holders:Nigel Barnes
/**********************************************************************

    Radofin Aquarius Quick Disk

    Specifications:
      Capacity            64K byte per side
      Read/Write time     64K/8sec
      Transmitting speed  101K [BPS]
      Recording density   4410 [BPI]
      Track density       59 [TPI]
      Number of track     1 (spiral)
      Recoding system     MFM
      Rotation speed      423 [RPM]
      Disk                2.8"
      Number of heads     1

    TODO:

    - floppy support (I/O 0xe6-0xe7 = drive 1, 0xea-0xeb = drive 2)

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


#include "emu.h"
#include "qdisk.h"


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

DEFINE_DEVICE_TYPE(AQUARIUS_QDISK, aquarius_qdisk_device, "aquarius_qdisk", "Aquarius Quick Disk")


//-------------------------------------------------
//  INPUT_PORTS( qdisk )
//-------------------------------------------------

static INPUT_PORTS_START(qdisk)
	PORT_START("SW1")
	PORT_DIPNAME(0x01, 0x00, "Drive Selection")
	PORT_DIPSETTING(0x00, "1")
	PORT_DIPSETTING(0x01, "2")
INPUT_PORTS_END


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

ioport_constructor aquarius_qdisk_device::device_input_ports() const
{
	return INPUT_PORTS_NAME(qdisk);
}


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

void aquarius_qdisk_device::device_add_mconfig(machine_config &config)
{
	MC6852(config, m_ssda, 6.5_MHz_XTAL);

	AQUARIUS_CARTRIDGE_SLOT(config, m_exp, DERIVED_CLOCK(1,1), aquarius_cartridge_devices, nullptr);
	m_exp->irq_handler().set(DEVICE_SELF_OWNER, FUNC(aquarius_cartridge_slot_device::irq_w));
	m_exp->nmi_handler().set(DEVICE_SELF_OWNER, FUNC(aquarius_cartridge_slot_device::nmi_w));
}


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

//-------------------------------------------------
//  aquarius_qdisk_device - constructor
//-------------------------------------------------

aquarius_qdisk_device::aquarius_qdisk_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, AQUARIUS_QDISK, tag, owner, clock)
	, device_aquarius_cartridge_interface(mconfig, *this)
	, m_ssda(*this, "mc6852")
	, m_exp(*this, "exp")
	, m_sw1(*this, "SW1")
{
}


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

void aquarius_qdisk_device::device_start()
{
}


//**************************************************************************
//  IMPLEMENTATION
//**************************************************************************

uint8_t aquarius_qdisk_device::mreq_r(offs_t offset)
{
	return m_exp->mreq_r(offset);
}

void aquarius_qdisk_device::mreq_w(offs_t offset, uint8_t data)
{
	m_exp->mreq_w(offset, data);
}


uint8_t aquarius_qdisk_device::mreq_ce_r(offs_t offset)
{
	uint8_t data = get_rom_base()[offset & 0x1fff];

	data &= m_exp->mreq_ce_r(offset);

	return data;
}

void aquarius_qdisk_device::mreq_ce_w(offs_t offset, uint8_t data)
{
	m_exp->mreq_ce_w(offset, data);
}


uint8_t aquarius_qdisk_device::iorq_r(offs_t offset)
{
	uint8_t data = m_exp->iorq_r(offset);

	switch (offset & 0xfe)
	{
	case 0xe6: case 0xea:
		if (BIT(offset, 3) == m_sw1->read())
		{
			data = m_ssda->read(offset & 0x01);
		}
		logerror("iorq_r: %02x = %02x\n", offset, data);
		break;
	}

	data &= m_exp->iorq_r(offset);

	return data;
}

void aquarius_qdisk_device::iorq_w(offs_t offset, uint8_t data)
{
	switch (offset & 0xfe)
	{
	case 0xe6: case 0xea:
		if (BIT(offset, 3) == m_sw1->read())
		{
			m_ssda->write(offset & 0x01, data);
		}
		logerror("iorq_w: %02x = %02x\n", offset, data);
		break;
	}

	m_exp->iorq_w(offset, data);
}