summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/a2bus/a2diskii.cpp
blob: 71f6895ea44a0772724d1cfd8aef1d68c8698c67 (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
// license:BSD-3-Clause
// copyright-holders:R. Belmont
/*********************************************************************

    a2diskii.c

    Implementation of the Apple II Disk II controller card

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

#include "emu.h"
#include "imagedev/flopdrv.h"
#include "formats/ap2_dsk.h"
#include "machine/appldriv.h"
#include "a2diskii.h"


/***************************************************************************
    PARAMETERS
***************************************************************************/

//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

DEFINE_DEVICE_TYPE(A2BUS_DISKII,    a2bus_diskii_device,    "a2diskii",   "Apple Disk II controller")
DEFINE_DEVICE_TYPE(A2BUS_IWM_FDC,   a2bus_iwmflop_device,   "a2iwm_flop", "Apple IWM floppy card")
DEFINE_DEVICE_TYPE(A2BUS_AGAT7_FDC, a2bus_agat7flop_device, "agat7_flop", "Agat-7 140K floppy card")

#define DISKII_ROM_REGION  "diskii_rom"
#define FDC_TAG            "diskii_fdc"

const applefdc_interface fdc_interface =
{
	apple525_set_lines,         /* set_lines */
	apple525_set_enable_lines,  /* set_enable_lines */

	apple525_read_data,         /* read_data */
	apple525_write_data,    /* write_data */
	apple525_read_status    /* read_status */
};

static const floppy_interface floppy_interface =
{
	FLOPPY_STANDARD_5_25_DSHD,
	LEGACY_FLOPPY_OPTIONS_NAME(apple2),
	"floppy_5_25"
};

MACHINE_CONFIG_FRAGMENT( diskii )
	MCFG_APPLEFDC_ADD(FDC_TAG, fdc_interface)
	MCFG_LEGACY_FLOPPY_APPLE_2_DRIVES_ADD(floppy_interface,15,16)
MACHINE_CONFIG_END

MACHINE_CONFIG_FRAGMENT( iwmflop )
	MCFG_IWM_ADD(FDC_TAG, fdc_interface)
	MCFG_LEGACY_FLOPPY_APPLE_2_DRIVES_ADD(floppy_interface,15,16)
MACHINE_CONFIG_END

ROM_START( diskii )
	ROM_REGION(0x100, DISKII_ROM_REGION, 0)
	ROM_LOAD( "341-0027-a.p5", 0x000000, 0x000100, CRC(ce7144f6) SHA1(d4181c9f046aafc3fb326b381baac809d9e38d16) )
ROM_END

ROM_START( agat7 )
	ROM_REGION(0x100, DISKII_ROM_REGION, 0)
	ROM_LOAD( "shugart7.rom", 0x0000, 0x0100, CRC(c6e4850c) SHA1(71626d3d2d4bbeeac2b77585b45a5566d20b8d34) )
ROM_END

//-------------------------------------------------
//  machine_config_additions - device-specific
//  machine configurations
//-------------------------------------------------

machine_config_constructor a2bus_floppy_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( diskii );
}

machine_config_constructor a2bus_iwmflop_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( iwmflop );
}

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

const tiny_rom_entry *a2bus_floppy_device::device_rom_region() const
{
	return ROM_NAME( diskii );
}

const tiny_rom_entry *a2bus_agat7flop_device::device_rom_region() const
{
	return ROM_NAME( agat7 );
}

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

a2bus_floppy_device::a2bus_floppy_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, type, tag, owner, clock),
	device_a2bus_card_interface(mconfig, *this),
	m_fdc(*this, FDC_TAG), m_rom(nullptr)
{
}

a2bus_diskii_device::a2bus_diskii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	a2bus_floppy_device(mconfig, A2BUS_DISKII, tag, owner, clock)
{
}

a2bus_iwmflop_device::a2bus_iwmflop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	a2bus_floppy_device(mconfig, A2BUS_IWM_FDC, tag, owner, clock)
{
}

a2bus_agat7flop_device::a2bus_agat7flop_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	a2bus_floppy_device(mconfig, A2BUS_AGAT7_FDC, tag, owner, clock)
{
}

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

void a2bus_floppy_device::device_start()
{
	// set_a2bus_device makes m_slot valid
	set_a2bus_device();

	m_rom = device().machine().root_device().memregion(this->subtag(DISKII_ROM_REGION).c_str())->base();
}

void a2bus_floppy_device::device_reset()
{
}


/*-------------------------------------------------
    read_c0nx - called for reads from this card's c0nx space
-------------------------------------------------*/

uint8_t a2bus_floppy_device::read_c0nx(address_space &space, uint8_t offset)
{
	return m_fdc->read(offset);
}


/*-------------------------------------------------
    write_c0nx - called for writes to this card's c0nx space
-------------------------------------------------*/

void a2bus_floppy_device::write_c0nx(address_space &space, uint8_t offset, uint8_t data)
{
	m_fdc->write(offset, data);
}

/*-------------------------------------------------
    read_cnxx - called for reads from this card's c0nx space
-------------------------------------------------*/

uint8_t a2bus_floppy_device::read_cnxx(address_space &space, uint8_t offset)
{
	return m_rom[offset];
}