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

    ace2x00.c

    Helpers for the Franklin Ace 2x00's slot 1 and 6 internal peripherals

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

#include "emu.h"
#include "ace2x00.h"

//#define VERBOSE 1
#include "logmacro.h"

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

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

DEFINE_DEVICE_TYPE(A2BUS_ACE2X00_SLOT1, a2bus_ace2x00_slot1_device, "ace2x00s1", "Franklin Ace 2x00 Parallel Port")
DEFINE_DEVICE_TYPE(A2BUS_ACE2X00_SLOT6, a2bus_ace2x00_slot6_device, "ace2x00s6", "Franklin Ace 2x00 Disk Port")

/***************************************************************************
    FUNCTION PROTOTYPES
***************************************************************************/

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

void a2bus_ace2x00_device::device_add_mconfig(machine_config &config)
{
}

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

a2bus_ace2x00_device::a2bus_ace2x00_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock) :
	device_t(mconfig, type, tag, owner, clock),
	device_a2bus_card_interface(mconfig, *this), m_rom(nullptr)
{
}

a2bus_ace2x00_slot1_device::a2bus_ace2x00_slot1_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	a2bus_ace2x00_device(mconfig, A2BUS_ACE2X00_SLOT1, tag, owner, clock)
{
}

a2bus_ace2x00_slot6_device::a2bus_ace2x00_slot6_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
	a2bus_ace2x00_device(mconfig, A2BUS_ACE2X00_SLOT6, tag, owner, clock),
	m_iwm(*this, "iwm"),
	m_floppy(*this, "%u", 0U)
{
}

//-------------------------------------------------
//  device_add_mconfig - add device configuration
//-------------------------------------------------
void a2bus_ace2x00_slot6_device::device_add_mconfig(machine_config &config)
{
	IWM(config, m_iwm, clock(), 1021800*2);
	m_iwm->phases_cb().set(FUNC(a2bus_ace2x00_slot6_device::phases_w));
	m_iwm->devsel_cb().set(FUNC(a2bus_ace2x00_slot6_device::devsel_w));
	applefdintf_device::add_525(config, m_floppy[0]);
	applefdintf_device::add_525(config, m_floppy[1]);
}

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

uint8_t a2bus_ace2x00_slot6_device::read_c0nx(u8 offset)
{
	return m_iwm->read(offset);
}

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

void a2bus_ace2x00_slot6_device::write_c0nx(u8 offset, u8 data)
{
	m_iwm->write(offset, data);
}

void a2bus_ace2x00_slot6_device::devsel_w(u8 data)
{
	if (data & 1)
		m_iwm->set_floppy(m_floppy[0]->get_device());
	else if (data & 2)
		m_iwm->set_floppy(m_floppy[1]->get_device());
	else
		m_iwm->set_floppy(nullptr);
}

void a2bus_ace2x00_slot6_device::phases_w(u8 data)
{
	auto flp = m_iwm->get_floppy();
	if (flp)
		flp->seek_phase_w(data);
}

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

void a2bus_ace2x00_device::device_start()
{
}

void a2bus_ace2x00_device::device_reset()
{
	m_rom = device().machine().root_device().memregion("maincpu")->base();
}

uint8_t a2bus_ace2x00_device::read_cnxx(uint8_t offset)
{
	switch (slotno())
	{
		case 1:
			return m_rom[offset];

		case 6:
			return m_rom[offset + 0x4600];
	}

	return 0xff;
}

uint8_t a2bus_ace2x00_device::read_c800(uint16_t offset)
{
	switch (slotno())
	{
		case 6:
			return m_rom[(offset & 0x7ff) + 0x4800];
	}

	return 0xff;
}

void a2bus_ace2x00_device::write_c800(uint16_t offset, uint8_t data)
{
}

bool a2bus_ace2x00_device::take_c800()
{
	switch (slotno())
	{
		case 6:
			return true;
		default:
			return false;
	}
}