/
rom.cpp
210 lines (156 loc) · 5.5 KB
/
rom.cpp
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
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli, Angelo Salese
/**************************************************************************************************
A800/A5200/XEGS ROM base cart emulation
**************************************************************************************************/
#include "emu.h"
#include "rom.h"
//-------------------------------------------------
// constructor
//-------------------------------------------------
DEFINE_DEVICE_TYPE(A800_ROM, a800_rom_device, "a800_rom", "Atari 8-bit ROM cart")
DEFINE_DEVICE_TYPE(A800_ROM_16KB, a800_rom_16kb_device, "a800_rom_16kb", "Atari 8-bit ROM 16kb cart")
DEFINE_DEVICE_TYPE(A800_ROM_RIGHT, a800_rom_right_device, "a800_rom_right","Atari 8-bit ROM Right cart")
DEFINE_DEVICE_TYPE(XEGS_ROM, xegs_rom_device, "a800_xegs", "Atari XEGS 64K cart")
DEFINE_DEVICE_TYPE(A5200_ROM, a5200_rom_device, "a5200_rom", "Atari 5200 ROM cart")
DEFINE_DEVICE_TYPE(A5200_ROM_2CHIPS, a5200_rom_2chips_device, "a5200_16k2c", "Atari 5200 ROM cart 16K in 2 Chips")
a800_rom_device::a800_rom_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_a800_cart_interface( mconfig, *this )
{
}
/*-------------------------------------------------
Generic left cart 8kb
-------------------------------------------------*/
a800_rom_device::a800_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: a800_rom_device(mconfig, A800_ROM, tag, owner, clock)
{
}
void a800_rom_device::device_start()
{
}
void a800_rom_device::device_reset()
{
}
void a800_rom_device::cart_map(address_map &map)
{
map(0x2000, 0x3fff).lr8(
NAME([this](offs_t offset) { return m_rom[offset & (m_rom_size - 1)]; })
);
}
/*-------------------------------------------------
Generic right cart 8kb
-------------------------------------------------*/
a800_rom_right_device::a800_rom_right_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: a800_rom_device(mconfig, A800_ROM_RIGHT, tag, owner, clock)
{
}
void a800_rom_right_device::device_start()
{
}
void a800_rom_right_device::device_reset()
{
rd4_w(1);
rd5_w(0);
}
void a800_rom_right_device::cart_map(address_map &map)
{
map(0x0000, 0x1fff).lr8(
NAME([this](offs_t offset) { return m_rom[offset & (m_rom_size - 1)]; })
);
}
/*-------------------------------------------------
Generic 16kb RD4 + RD5 cart
-------------------------------------------------*/
a800_rom_16kb_device::a800_rom_16kb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: a800_rom_device(mconfig, A800_ROM_16KB, tag, owner, clock)
{
}
void a800_rom_16kb_device::device_start()
{
}
void a800_rom_16kb_device::device_reset()
{
rd_both_w(1);
}
void a800_rom_16kb_device::cart_map(address_map &map)
{
map(0x0000, 0x3fff).lr8(
NAME([this](offs_t offset) { return m_rom[offset & (m_rom_size - 1)]; })
);
}
/*-------------------------------------------------
XEGS carts (32K, 64K or 128K)
-------------------------------------------------*/
xegs_rom_device::xegs_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: a800_rom_device(mconfig, XEGS_ROM, tag, owner, clock)
, m_bank(0)
{
}
void xegs_rom_device::device_start()
{
save_item(NAME(m_bank));
}
void xegs_rom_device::device_reset()
{
// TODO: random
m_bank = 0;
}
// RD5 always maps to the last bank
void xegs_rom_device::cart_map(address_map &map)
{
map(0x0000, 0x1fff).lr8(
NAME([this](offs_t offset) { return m_rom[(offset & 0x1fff) + (m_bank * 0x2000)]; })
);
map(0x2000, 0x3fff).lr8(
NAME([this](offs_t offset) { return m_rom[(offset & 0x1fff) + (m_bank_mask * 0x2000)]; })
);
}
void xegs_rom_device::cctl_map(address_map &map)
{
map(0x00, 0xff).lw8(
NAME([this](offs_t offset, u8 data) { m_bank = data & m_bank_mask; })
);
}
// Atari 5200
/*-------------------------------------------------
Carts with no bankswitch (4K, 8K, 16K, 32K)
Same as base carts above
-------------------------------------------------*/
a5200_rom_device::a5200_rom_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_a5200_cart_interface( mconfig, *this )
{
}
a5200_rom_device::a5200_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: a5200_rom_device(mconfig, A5200_ROM, tag, owner, clock)
{
}
void a5200_rom_device::cart_map(address_map &map)
{
map(0x0000, 0x7fff).lr8(
NAME([this](offs_t offset) { return m_rom[(offset & (m_rom_size - 1))]; })
);
}
void a5200_rom_device::device_start()
{
}
/*-------------------------------------------------
Carts with 2x8K (16K) with A13 line not connected
Range 0x4000-0x7fff contains two copies of the low
8K, range 0x8000-0xbfff contains two copies of the
high 8K
-------------------------------------------------*/
a5200_rom_2chips_device::a5200_rom_2chips_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: a5200_rom_device(mconfig, A5200_ROM_2CHIPS, tag, owner, clock)
{
}
void a5200_rom_2chips_device::cart_map(address_map &map)
{
map(0x0000, 0x3fff).lr8(
NAME([this](offs_t offset) { return m_rom[offset & 0x1fff]; })
);
map(0x4000, 0x7fff).lr8(
NAME([this](offs_t offset) { return m_rom[(offset & 0x1fff) + 0x2000]; })
);
}