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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
// license:BSD-3-Clause
// copyright-holders:Curt Coder
/**********************************************************************
Multiscreen cartridge emulation
Copyright MESS Team.
Visit http://mamedev.org for licensing and usage restrictions.
**********************************************************************/
/*
PCB Layout
----------
|===================|
| ROM6 |
| MC14066 |
| |
|===============| ROM5 |
|=| |
|=| |
|=| RAM BAT ROM4 |
|=| |
|=| |
|=| ROM0 ROM3 |
|=| |
|=| |
|===============| LS138 ROM2 |
| LS138 |
| LS174 |
| LS133 ROM1 |
|===================|
BAT - BR2325 lithium battery
RAM - ? 8Kx8 RAM
ROM0 - ? 16Kx8 EPROM
ROM1 - ? 32Kx8 EPROM
ROM2 - ? 32Kx8 EPROM
ROM3 - ? 32Kx8 EPROM
ROM4 - not populated
ROM5 - not populated
ROM6 - not populated
*/
/*
TODO:
- M6802 board
- crashes on boot
805A: lda $01
805C: and #$FE
805E: sta $01
8060: m6502_brk#$00 <-- BOOM!
*/
#include "multiscreen.h"
//**************************************************************************
// MACROS/CONSTANTS
//**************************************************************************
#define MC6802P_TAG "m6802"
#define MC6821P_0_TAG "m6821_0"
#define MC6821P_1_TAG "m6821_1"
#define BANK_RAM 0x0d
//**************************************************************************
// DEVICE DEFINITIONS
//**************************************************************************
const device_type C64_MULTISCREEN = &device_creator<c64_multiscreen_cartridge_device>;
//-------------------------------------------------
// ROM( c64_multiscreen )
//-------------------------------------------------
ROM_START( c64_multiscreen )
ROM_REGION( 0x2000, MC6802P_TAG, 0 )
ROM_LOAD( "1", 0x0000, 0x1000, CRC(35be02a8) SHA1(5912bc3d8e0c0949c1e66c19116d6b71c7574e46) )
ROM_LOAD( "2 cr", 0x1000, 0x1000, CRC(76a9ac6d) SHA1(87e7335e626bdb73498b46c28c7baab72df38d1f) )
ROM_END
//-------------------------------------------------
// rom_region - device-specific ROM region
//-------------------------------------------------
const rom_entry *c64_multiscreen_cartridge_device::device_rom_region() const
{
return ROM_NAME( c64_multiscreen );
}
static ADDRESS_MAP_START( multiscreen_mem, AS_PROGRAM, 8, c64_multiscreen_cartridge_device )
AM_RANGE(0x0000, 0x1fff) AM_ROM AM_REGION(MC6802P_TAG, 0)
ADDRESS_MAP_END
//-------------------------------------------------
// pia6821_interface pia0_intf -
//-------------------------------------------------
static const pia6821_interface pia0_intf =
{
DEVCB_NULL, // input A
DEVCB_NULL, // input B
DEVCB_NULL, // input CA1
DEVCB_NULL, // input CB1
DEVCB_NULL, // input CA2
DEVCB_NULL, // input CB2
DEVCB_NULL, // output A
DEVCB_NULL, // output B
DEVCB_NULL, // output CA2
DEVCB_NULL, // output CB2
DEVCB_NULL, // irq A
DEVCB_NULL // irq B
};
//-------------------------------------------------
// pia6821_interface pia1_intf -
//-------------------------------------------------
static const pia6821_interface pia1_intf =
{
DEVCB_NULL, // input A
DEVCB_NULL, // input B
DEVCB_NULL, // input CA1
DEVCB_NULL, // input CB1
DEVCB_NULL, // input CA2
DEVCB_NULL, // input CB2
DEVCB_NULL, // output A
DEVCB_NULL, // output B
DEVCB_NULL, // output CA2
DEVCB_NULL, // output CB2
DEVCB_NULL, // irq A
DEVCB_NULL // irq B
};
//-------------------------------------------------
// MACHINE_CONFIG_FRAGMENT( c64_multiscreen )
//-------------------------------------------------
static MACHINE_CONFIG_FRAGMENT( c64_multiscreen )
MCFG_CPU_ADD(MC6802P_TAG, M6802, XTAL_4MHz)
MCFG_CPU_PROGRAM_MAP(multiscreen_mem)
MCFG_PIA6821_ADD(MC6821P_0_TAG, pia0_intf)
MCFG_PIA6821_ADD(MC6821P_1_TAG, pia1_intf)
MACHINE_CONFIG_END
//-------------------------------------------------
// machine_config_additions - device-specific
// machine configurations
//-------------------------------------------------
machine_config_constructor c64_multiscreen_cartridge_device::device_mconfig_additions() const
{
return MACHINE_CONFIG_NAME( c64_multiscreen );
}
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// c64_multiscreen_cartridge_device - constructor
//-------------------------------------------------
c64_multiscreen_cartridge_device::c64_multiscreen_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
device_t(mconfig, C64_MULTISCREEN, "C64 Multiscreen cartridge", tag, owner, clock, "c64_mscr", __FILE__),
device_c64_expansion_card_interface(mconfig, *this)
{
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void c64_multiscreen_cartridge_device::device_start()
{
// state saving
save_item(NAME(m_bank));
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void c64_multiscreen_cartridge_device::device_reset()
{
m_bank = 0;
}
//-------------------------------------------------
// c64_cd_r - cartridge data read
//-------------------------------------------------
UINT8 c64_multiscreen_cartridge_device::c64_cd_r(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2)
{
if (!roml)
{
int bank = m_bank & 0x0f;
if (bank == BANK_RAM)
{
data = m_nvram[offset & 0x1fff];
}
else
{
data = m_roml[(bank << 14) | (offset & 0x3fff)];
}
}
else if (!romh)
{
int bank = m_bank & 0x0f;
if (bank == BANK_RAM)
{
data = m_roml[offset & 0x3fff];
}
else
{
data = m_roml[(bank << 14) | (offset & 0x3fff)];
}
}
return data;
}
//-------------------------------------------------
// c64_cd_w - cartridge data write
//-------------------------------------------------
void c64_multiscreen_cartridge_device::c64_cd_w(address_space &space, offs_t offset, UINT8 data, int sphi2, int ba, int roml, int romh, int io1, int io2)
{
if (offset >= 0x8000 && offset < 0xa000)
{
int bank = m_bank & 0x0f;
if (bank == BANK_RAM)
{
m_nvram[offset & 0x1fff] = data;
}
}
else if (!io2)
{
m_bank = data;
}
}
|