summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/bus/a800/oss.c
blob: 3df4f2b0ed40ccbc28d73da29a5d4c9b5c692dcf (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
248
249
250
251
252
// license:BSD-3-Clause
// copyright-holders:etabeta
/***********************************************************************************************************

 A800 ROM cart emulation

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


#include "emu.h"
#include "oss.h"


//-------------------------------------------------
//  constructor
//-------------------------------------------------

const device_type A800_ROM_OSS8K = &device_creator<a800_rom_oss8k_device>;
const device_type A800_ROM_OSS34 = &device_creator<a800_rom_oss34_device>;
const device_type A800_ROM_OSS43 = &device_creator<a800_rom_oss43_device>;
const device_type A800_ROM_OSS91 = &device_creator<a800_rom_oss91_device>;


a800_rom_oss8k_device::a800_rom_oss8k_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: a800_rom_device(mconfig, A800_ROM_OSS8K, "Atari 800 ROM Carts OSS 8K", tag, owner, clock, "a800_oss8k", __FILE__)
{
}


a800_rom_oss34_device::a800_rom_oss34_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: a800_rom_device(mconfig, A800_ROM_OSS34, "Atari 800 ROM Carts OSS-034M", tag, owner, clock, "a800_034m", __FILE__)
{
}


a800_rom_oss43_device::a800_rom_oss43_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: a800_rom_device(mconfig, A800_ROM_OSS43, "Atari 800 ROM Carts OSS-043M", tag, owner, clock, "a800_043m", __FILE__)
{
}


a800_rom_oss91_device::a800_rom_oss91_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
					: a800_rom_device(mconfig, A800_ROM_OSS91, "Atari 800 ROM Carts OSS-M091", tag, owner, clock, "a800_m091", __FILE__)
{
}



void a800_rom_oss8k_device::device_start()
{
	save_item(NAME(m_bank));
}

void a800_rom_oss8k_device::device_reset()
{
	m_bank = 0;
}


void a800_rom_oss34_device::device_start()
{
	save_item(NAME(m_bank));
}

void a800_rom_oss34_device::device_reset()
{
	m_bank = 1;
}


void a800_rom_oss43_device::device_start()
{
	save_item(NAME(m_bank));
}

void a800_rom_oss43_device::device_reset()
{
	m_bank = 0;
}


void a800_rom_oss91_device::device_start()
{
	save_item(NAME(m_bank));
}

void a800_rom_oss91_device::device_reset()
{
	m_bank = 0;
}


/*-------------------------------------------------
 mapper specific handlers
 -------------------------------------------------*/

/*-------------------------------------------------

 OSS 8K

 This is used by The Writer's Tool only.

 -------------------------------------------------*/

READ8_MEMBER(a800_rom_oss8k_device::read_80xx)
{
	if (offset >= 0x1000)
		return m_rom[offset & 0xfff];
	else
		return m_rom[(offset & 0xfff) + (m_bank * 0x1000)];
}

WRITE8_MEMBER(a800_rom_oss8k_device::write_d5xx)
{
	switch (offset & 0x09)
	{
		case 0:
		case 1:
			m_bank = 1;
			break;
		case 9:
			m_bank = 0;
			break;
		default:
			break;
	}
}


/*-------------------------------------------------

 OSS 034M

 This apparently comes from a dump with the wrong bank order...
 investigate whether we should remove it!

 -------------------------------------------------*/

READ8_MEMBER(a800_rom_oss34_device::read_80xx)
{
	if (offset >= 0x1000)
		return m_rom[(offset & 0xfff) + 0x3000];
	else if (m_bank == 3)
		return 0xff;
	else
		return m_rom[(offset & 0xfff) + (m_bank * 0x1000)];
}

WRITE8_MEMBER(a800_rom_oss34_device::write_d5xx)
{
	switch (offset & 0x0f)
	{
		case 0:
		case 1:
			m_bank = 0;
			break;
		case 2:
		case 6:
			m_bank = 3; // in this case the ROM gets disabled and 0xff is returned in 0xa000-0xafff
			break;
		case 3:
		case 7:
			m_bank = 1;
			break;
		case 4:
		case 5:
			m_bank = 2;
			break;
		default:
			break;
	}
}


/*-------------------------------------------------

 OSS 043M

 Same as above but with correct bank order

 -------------------------------------------------*/

READ8_MEMBER(a800_rom_oss43_device::read_80xx)
{
	if (offset >= 0x1000)
		return m_rom[(offset & 0xfff) + 0x3000];
	else if (m_bank == 3)
		return 0xff;
	else
		return m_rom[(offset & 0xfff) + (m_bank * 0x1000)];
}

WRITE8_MEMBER(a800_rom_oss43_device::write_d5xx)
{
	switch (offset & 0x0f)
	{
		case 0:
		case 1:
			m_bank = 0;
			break;
		case 2:
		case 6:
			m_bank = 3; // in this case the ROM gets disabled and 0xff is returned in 0xa000-0xafff
			break;
		case 3:
		case 7:
			m_bank = 2;
			break;
		case 4:
		case 5:
			m_bank = 1;
			break;
		default:
			break;
	}
}


/*-------------------------------------------------

 OSS M091

 Simplified banking system which only uses two
 address lines (A0 & A3)

 -------------------------------------------------*/

READ8_MEMBER(a800_rom_oss91_device::read_80xx)
{
	if (offset >= 0x1000)
		return m_rom[offset & 0xfff];
	else
		return m_rom[(offset & 0xfff) + (m_bank * 0x1000)];
}

WRITE8_MEMBER(a800_rom_oss91_device::write_d5xx)
{
	switch (offset & 0x09)
	{
		case 0:
			m_bank = 1;
			break;
		case 1:
			m_bank = 3;
			break;
		case 9:
			m_bank = 2;
			break;
		default:
			break;
	}
}