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
|
/***********************************************************************************************************
Epoch Super Cassette Vision cart emulation
***********************************************************************************************************/
#include "emu.h"
#include "rom.h"
//-------------------------------------------------
// scv_rom_device - constructor
//-------------------------------------------------
const device_type SCV_ROM8K = &device_creator<scv_rom8_device>;
const device_type SCV_ROM16K = &device_creator<scv_rom16_device>;
const device_type SCV_ROM32K = &device_creator<scv_rom32_device>;
const device_type SCV_ROM32K_RAM8K = &device_creator<scv_rom32ram8_device>;
const device_type SCV_ROM64K = &device_creator<scv_rom64_device>;
const device_type SCV_ROM128K = &device_creator<scv_rom128_device>;
const device_type SCV_ROM128K_RAM4K = &device_creator<scv_rom128ram4_device>;
scv_rom8_device::scv_rom8_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_scv_cart_interface( mconfig, *this )
{
}
scv_rom8_device::scv_rom8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: device_t(mconfig, SCV_ROM8K, "SCV 8K Carts", tag, owner, clock, "scv_rom8", __FILE__),
device_scv_cart_interface( mconfig, *this )
{
}
scv_rom16_device::scv_rom16_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: scv_rom8_device(mconfig, SCV_ROM16K, "SCV 16K Carts", tag, owner, clock, "scv_rom16", __FILE__)
{
}
scv_rom32_device::scv_rom32_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: scv_rom8_device(mconfig, SCV_ROM32K, "SCV 32K Carts", tag, owner, clock, "scv_rom32", __FILE__)
{
}
scv_rom32ram8_device::scv_rom32ram8_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: scv_rom8_device(mconfig, SCV_ROM32K_RAM8K, "SCV 32K + RAM 8K Carts", tag, owner, clock, "scv_rom32_ram8", __FILE__)
{
}
scv_rom64_device::scv_rom64_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: scv_rom8_device(mconfig, SCV_ROM16K, "SCV 64K Carts", tag, owner, clock, "scv_rom64", __FILE__)
{
}
scv_rom128_device::scv_rom128_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: scv_rom8_device(mconfig, SCV_ROM32K, "SCV 128K Carts", tag, owner, clock, "scv_rom128", __FILE__)
{
}
scv_rom128ram4_device::scv_rom128ram4_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
: scv_rom8_device(mconfig, SCV_ROM128K_RAM4K, "SCV 128K + RAM 4K Carts", tag, owner, clock, "scv_rom128_ram4", __FILE__)
{
}
//-------------------------------------------------
// mapper specific start/reset
//-------------------------------------------------
void scv_rom32ram8_device::device_start()
{
save_item(NAME(m_ram_enabled));
}
void scv_rom32ram8_device::device_reset()
{
m_ram_enabled = 1;
}
void scv_rom64_device::device_start()
{
save_item(NAME(m_bank_base));
}
void scv_rom64_device::device_reset()
{
m_bank_base = 0;
}
void scv_rom128_device::device_start()
{
save_item(NAME(m_bank_base));
}
void scv_rom128_device::device_reset()
{
m_bank_base = 0;
}
void scv_rom128ram4_device::device_start()
{
save_item(NAME(m_bank_base));
save_item(NAME(m_ram_enabled));
}
void scv_rom128ram4_device::device_reset()
{
m_bank_base = 0;
m_ram_enabled = 1;
}
/*-------------------------------------------------
mapper specific handlers
-------------------------------------------------*/
READ8_MEMBER(scv_rom8_device::read_cart)
{
return m_rom[offset & 0x1fff];
}
READ8_MEMBER(scv_rom16_device::read_cart)
{
return m_rom[offset & 0x3fff];
}
READ8_MEMBER(scv_rom32_device::read_cart)
{
return m_rom[offset];
}
READ8_MEMBER(scv_rom32ram8_device::read_cart)
{
if (m_ram_enabled && offset >= 0x6000)
return m_ram[offset & 0x1fff];
return m_rom[offset];
}
WRITE8_MEMBER(scv_rom32ram8_device::write_cart)
{
if (m_ram_enabled && offset >= 0x6000)
m_ram[offset & 0x1fff] = data;
}
WRITE8_MEMBER(scv_rom32ram8_device::write_bank)
{
m_ram_enabled = BIT(data, 5);
}
READ8_MEMBER(scv_rom64_device::read_cart)
{
return m_rom[offset + (m_bank_base * 0x8000)];
}
WRITE8_MEMBER(scv_rom64_device::write_bank)
{
m_bank_base = BIT(data, 5);
}
READ8_MEMBER(scv_rom128_device::read_cart)
{
return m_rom[offset + (m_bank_base * 0x8000)];
}
WRITE8_MEMBER(scv_rom128_device::write_bank)
{
m_bank_base = (data >> 5) & 0x03;
}
READ8_MEMBER(scv_rom128ram4_device::read_cart)
{
if (m_ram_enabled && offset >= 0x7000)
return m_ram[offset & 0xfff];
return m_rom[offset + (m_bank_base * 0x8000)];
}
WRITE8_MEMBER(scv_rom128ram4_device::write_cart)
{
if (m_ram_enabled && offset >= 0x7000)
m_ram[offset & 0xfff] = data;
}
WRITE8_MEMBER(scv_rom128ram4_device::write_bank)
{
m_bank_base = (data >> 5) & 0x03;
m_ram_enabled = BIT(data, 6);
}
|