summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/a2bus/q68.cpp
blob: 4729f450e4a6ba9a5d36ea1e5a1dcd510a2ee239 (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
// license:BSD-3-Clause
// copyright-holders:Rob Justice, R. Belmont
/*********************************************************************

    q68.cpp

    Implementation of the Stellation Q-68 68008 card

    Memory Map
    68008 0x00000-0x0ffff -> Apple II memory
    68008 0x10000-0x17fff -> Onboard EPROM, 8k (expandable to 32k)
    68008 0x18000-0x1ffff -> Onboard RAM, 8K (expandable to 32k?)
    68008 0x20000-0xfffff -> Open, for options via expansion connector

    Apple II Memory
    68008 0x00000-0x003ff -> 6502 0x0800-0x0bff
    68008 0x00400-0x007ff -> 6502 0x0400-0x07ff
    68008 0x00800-0x00bff -> 6502 0x0000-0x03ff
    68008 0x00c00-0x0ffff -> 6502 0x0c00-0xffff

    0xc0n1 - Turn card on
    0xc0n3 - Interrupt card
    0xc0n0 - Turn card off

    Also includes the Q-68 plus version made by nanja.info
    This has a full 1MB of ram on board and slight update to the memory map
    Memory Map
    68008 0x00000-0x0ffff -> Apple II memory
    68008 0x10000-0x11fff -> Onboard EPROM, 8k
    68008 0x12000-0x1ffff -> Onboard RAM, ~1MB

    Todo:
    Implement Watchdog timer. Only relevant to Q-68 and bus errors for nonexistent memory access
    Speed of 6502 should be slower when 68008 is enabled and accessing AppleII memory space
    Speed of 68008 should be slower when access the Apple II memory space

    (reference: http://mirrors.apple2.org.za/ftp.apple.asimov.net/unsorted/QPAK-68%20Users%20Guide.pdf )

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

#include "emu.h"
#include "q68.h"

#include "cpu/m68000/m68008.h"


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

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

DEFINE_DEVICE_TYPE(A2BUS_Q68, a2bus_q68_device, "a2q68", "Stellation Two Q-68")
DEFINE_DEVICE_TYPE(A2BUS_Q68PLUS, a2bus_q68plus_device, "a2q68plus", "Stellation Two Q-68 Plus")

void a2bus_q68_device::m68008_mem(address_map &map)
{
	map(0x00000, 0x0ffff).rw(FUNC(a2bus_q68_device::dma_r), FUNC(a2bus_q68_device::dma_w));
	map(0x10000, 0x11fff).mirror(0x6000).rom(); // 8k debug rom
	map(0x18000, 0x19fff).mirror(0x6000).ram(); // 8k of ram
}

void a2bus_q68plus_device::m68008_mem(address_map &map)
{
	map(0x00000, 0x0ffff).rw(FUNC(a2bus_q68plus_device::dma_r), FUNC(a2bus_q68plus_device::dma_w));
	map(0x10000, 0x11fff).rom(); // 8k debug rom
	map(0x12000, 0xfffff).ram(); // 1 MB of RAM
}

ROM_START( q68 )
	ROM_REGION(0x100000, "m68008", 0)
	ROM_LOAD( "debug1.04-caf4.bin", 0x10000, 0x02000, CRC(6bead126) SHA1(e46d5e8256faece3723e9040f78fd1c8edb3ee0e) )
ROM_END

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

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

void a2bus_q68_device::device_add_mconfig(machine_config &config)
{
	M68008(config, m_m68008, 1021800*7); // M68008 runs at 7.16 MHz
	m_m68008->set_addrmap(AS_PROGRAM, &a2bus_q68_device::m68008_mem);
}

void a2bus_q68plus_device::device_add_mconfig(machine_config &config)
{
	M68008(config, m_m68008, 1021800*7); // M68008 runs at 7.16 MHz
	m_m68008->set_addrmap(AS_PROGRAM, &a2bus_q68plus_device::m68008_mem);
}

//-------------------------------------------------
//  device_rom_region - device-specific ROMs
//-------------------------------------------------

const tiny_rom_entry *a2bus_68k_device::device_rom_region() const
{
	return ROM_NAME( q68 );
}

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

a2bus_68k_device::a2bus_68k_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_m68008(*this, "m68008")
	, m_bEnabled(false)
{
}

a2bus_q68_device::a2bus_q68_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	a2bus_68k_device(mconfig, A2BUS_Q68, tag, owner, clock)
{
}

a2bus_q68plus_device::a2bus_q68plus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	a2bus_68k_device(mconfig, A2BUS_Q68PLUS, tag, owner, clock)
{
}

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

void a2bus_68k_device::device_start()
{
	save_item(NAME(m_bEnabled));
}

void a2bus_68k_device::device_reset()
{
	m_m68008->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
	m_m68008->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
	m_bEnabled=false;
}

uint8_t a2bus_68k_device::read_c0nx(uint8_t offset)
{
	switch (offset & 0x3)
	{
		case 0:
		case 2:
			m_m68008->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
			m_m68008->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
			m_bEnabled=false;
			break;

		case 1:
			m_m68008->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
			m_m68008->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
			m_bEnabled=true;
			break;

		case 3:
			m_m68008->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
			m_m68008->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
			m_bEnabled=true;
			m_m68008->pulse_input_line(M68K_IRQ_7, attotime::zero);  //work around, processor status lines + logic should clear nmi.
			break;
	}
	return 0;
}

void a2bus_68k_device::write_c0nx(uint8_t offset, uint8_t data)
{
	switch (offset & 0x3)
	{
		case 0:
		case 2:
			m_m68008->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
			m_m68008->set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
			m_bEnabled=false;
			break;

		case 1:
			m_m68008->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
			m_m68008->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
			m_bEnabled=true;
			break;

		case 3:
			m_m68008->set_input_line(INPUT_LINE_RESET, CLEAR_LINE);
			m_m68008->set_input_line(INPUT_LINE_HALT, CLEAR_LINE);
			m_bEnabled=true;
			m_m68008->pulse_input_line(M68K_IRQ_7, attotime::zero);  //work around, processor status lines should clear nmi.
			break;
	}
}

uint8_t a2bus_68k_device::dma_r(offs_t offset)
{
	if (m_bEnabled)
	{
		if (offset <= 0x03ff)        //0x0000-0x03ff
		{
			return slot_dma_read(offset+0x800);
		}
		else if (offset <= 0x07ff)   //0x0400-0x07ff
		{
			return slot_dma_read(offset);
		}
		else if (offset <= 0x0bff)   //0x0800-0x0bff
		{
			return slot_dma_read(offset-0x800);
		}
		else if (offset <= 0xffff)   //0x0c00-0xffff
		{
			return slot_dma_read(offset);
		}
	}
	return 0xff;
}


//-------------------------------------------------
//  dma_w -
//-------------------------------------------------

void a2bus_68k_device::dma_w(offs_t offset, uint8_t data)
{
	if (m_bEnabled)
	{
		if (offset <= 0x03ff)        //0x0000-0x03ff
		{
			return slot_dma_write(offset+0x800, data);
		}
		else if (offset <= 0x07ff)   //0x0400-0x07ff
		{
			return slot_dma_write(offset, data);
		}
		else if (offset <= 0x0bff)   //0x0800-0x0bff
		{
			return slot_dma_write(offset-0x800, data);
		}
		else if (offset <= 0xffff)   //0x0c00-0xffff
		{
			return slot_dma_write(offset, data);
		}
	}
}