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

    Micro Innovations Powermate IDE Hard Disk emulation

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

/*

    TODO:

    - parallel status port
    - memory bank switching port
    - boot ROM

*/

#include "emu.h"
#include "ide.h"
#include "bus/centronics/ctronics.h"



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

#define ATA_TAG             "ata"
#define CENTRONICS_TAG      "centronics"



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

DEFINE_DEVICE_TYPE(ADAM_IDE, powermate_ide_device, "adam_ide", "Powermate HP IDE")


//-------------------------------------------------
//  ROM( adam_ata )
//-------------------------------------------------

ROM_START( adam_ata )
	ROM_REGION( 0x1000, "rom", 0 )
	ROM_LOAD( "exp.rom", 0x0000, 0x1000, NO_DUMP )
ROM_END


//-------------------------------------------------
//  rom_region - device-specific ROM region
//-------------------------------------------------

const tiny_rom_entry *powermate_ide_device::device_rom_region() const
{
	return ROM_NAME( adam_ata );
}


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

void powermate_ide_device::device_add_mconfig(machine_config &config)
{
	ATA_INTERFACE(config, m_ata).options(ata_devices, "hdd", nullptr, false);
	centronics_device &centronics(CENTRONICS(config, CENTRONICS_TAG, centronics_devices, "printer"));

	OUTPUT_LATCH(config, m_cent_data_out);
	centronics.set_output_latch(*m_cent_data_out);
}



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

//-------------------------------------------------
//  powermate_ide_device - constructor
//-------------------------------------------------

powermate_ide_device::powermate_ide_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: device_t(mconfig, ADAM_IDE, tag, owner, clock),
		device_adam_expansion_slot_card_interface(mconfig, *this),
		m_ata(*this, ATA_TAG),
		m_cent_data_out(*this, "cent_data_out"), m_ata_data(0)
{
}


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

void powermate_ide_device::device_start()
{
}


//-------------------------------------------------
//  adam_bd_r - buffered data read
//-------------------------------------------------

uint8_t powermate_ide_device::adam_bd_r(address_space &space, offs_t offset, uint8_t data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2)
{
	if (!biorq)
	{
		switch (offset & 0xff)
		{
		case 0x01:
		case 0x02:
		case 0x03:
		case 0x04:
		case 0x05:
		case 0x06:
		case 0x07:
			data = m_ata->read_cs0(offset & 0x07, 0xff);
			break;

		case 0x40: // Printer status
			/*

			    bit     description

			    0
			    1
			    2
			    3
			    4
			    5
			    6
			    7

			*/
			break;

		case 0x58:
			m_ata_data = m_ata->read_cs0(0);

			data = m_ata_data & 0xff;
			break;

		case 0x59:
			data = m_ata_data >> 8;
			break;

		case 0x5a:
			data = m_ata->read_cs1(6, 0xff);
			break;

		case 0x5b: // Digital Input Register
			data = 0xff;
			break;
		}
	}

	return data;
}


//-------------------------------------------------
//  adam_bd_w - buffered data write
//-------------------------------------------------

void powermate_ide_device::adam_bd_w(address_space &space, offs_t offset, uint8_t data, int bmreq, int biorq, int aux_rom_cs, int cas1, int cas2)
{
	if (!biorq)
	{
		switch (offset & 0xff)
		{
		case 0x02:
		case 0x03:
		case 0x04:
		case 0x05:
		case 0x06:
		case 0x07:
			m_ata->write_cs0(offset & 0x07, data, 0xff);
			break;

		case 0x40:
			m_cent_data_out->write(data);
			break;

		case 0x42: // Bank Number
			break;

		case 0x58:
			m_ata_data |= data;
			m_ata->write_cs0(0, m_ata_data);
			break;

		case 0x59:
			m_ata_data = data << 8;
			break;

		case 0x5a: // Fixed Disk Control Register
			break;
		}
	}
}