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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
// license:BSD-3-Clause
// copyright-holders:David Haywood
/***************************************************************************
xavix.cpp
The dies for these are marked
SSD 97 PA7270-107 (only seen on Ping Pong)
SSD 98 PA7351-107
SSD 98 PL7351-181
6502 with custom opcodes
integrated gfx / sound
special notes
0x0000-0x7fff seems to be a 'low bus' area, it is always the same regardless
of banking
0x8000-0xffff is a banked area with individual code and data banks
Zero Page notes:
0x00ff contains the DATA bank, set manually in code
0x00fe appears to be the current CODE bank, set with either the
custom opcodes, or manually (if running from lowbus only?)
***************************************************************************/
#include "emu.h"
#include "xavix.h"
#include "xavixd.h"
DEFINE_DEVICE_TYPE(XAVIX, xavix_device, "xavix", "XaviX (SSD 97 / SSD 98)")
xavix_device::xavix_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock) :
xavix_device(mconfig, XAVIX, tag, owner, clock)
{
}
xavix_device::xavix_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, const XTAL &clock) :
m6502_device(mconfig, type, tag, owner, clock),
XPC(0),
m_lowbus_config("lowbus", ENDIANNESS_LITTLE, 8, 15),
m_extbus_config("extbus", ENDIANNESS_LITTLE, 8, 24),
m_vector_callback(*this)
{
program_config.m_addr_width = 24;
program_config.m_logaddr_width = 24;
sprogram_config.m_addr_width = 24;
sprogram_config.m_logaddr_width = 24;
// XaviX specific spaces
m_lowbus_config.m_addr_width = 15;
m_lowbus_config.m_logaddr_width = 15;
m_extbus_config.m_addr_width = 24;
m_extbus_config.m_logaddr_width = 24;
}
std::unique_ptr<util::disasm_interface> xavix_device::create_disassembler()
{
return std::make_unique<xavix_disassembler>();
}
offs_t xavix_device::pc_to_external(u16 pc)
{
return adr_with_codebank(pc);
}
void xavix_device::device_start()
{
mintf = std::make_unique<mi_xavix>(this);
// bind delegates
m_vector_callback.resolve();
init();
m_lowbus_space = &space(5);
m_extbus_space = &space(6);
state_add(XAVIX_DATABANK, "DATBNK", m_databank).callimport().formatstr("%2s");
state_add(XAVIX_CODEBANK, "CODBNK", m_codebank).callimport().formatstr("%2s");
save_item(NAME(m_special_stack));
save_item(NAME(m_special_stackpos));
}
void xavix_device::device_reset()
{
m_special_stackpos = 0xff;
for (int i = 0; i < 0x100; i++)
m_special_stack[i] = 0x00;
set_codebank(0);
set_databank(0);
m6502_device::device_reset();
}
xavix_device::mi_xavix::mi_xavix(xavix_device *_base)
{
base = _base;
}
void xavix_device::write_special_stack(uint8_t data)
{
m_special_stack[m_special_stackpos&0xff] = data;
}
void xavix_device::dec_special_stack()
{
m_special_stackpos--;
}
void xavix_device::inc_special_stack()
{
m_special_stackpos++;
}
uint8_t xavix_device::read_special_stack()
{
return m_special_stack[m_special_stackpos&0xff];
}
uint8_t xavix_device::read_full_data(uint32_t addr)
{
return read_full_data((addr & 0xff0000)>>16, addr & 0xffff);
}
inline uint8_t xavix_device::read_full_data(uint8_t databank, uint16_t adr)
{
if (databank < 0x80)
{
if (adr < 0x8000)
{
if (adr == 0xfe)
{
return m_codebank;
}
else if (adr == 0xff)
{
return m_databank;
}
return m_lowbus_space->read_byte(adr);
}
else
{
return m_extbus_space->read_byte((databank << 16) | adr);
}
}
else
{
return m_extbus_space->read_byte((databank << 16) | adr);
}
}
// data reads
inline uint8_t xavix_device::mi_xavix::read(uint16_t adr)
{
uint8_t databank = base->get_databank();
return base->read_full_data(databank, adr);
}
// opcode reads
uint8_t xavix_device::mi_xavix::read_sync(uint16_t adr)
{
return csprogram.read_byte(base->adr_with_codebank(adr));
}
// oprand reads
uint8_t xavix_device::mi_xavix::read_arg(uint16_t adr)
{
return cprogram.read_byte(base->adr_with_codebank(adr));
}
// data writes
void xavix_device::write_full_data(uint32_t addr, uint8_t val)
{
write_full_data((addr & 0xff0000)>>16, addr & 0xffff, val);
}
uint8_t xavix_device::read_stack(uint32_t addr)
{
// address is always 0x100-0x1ff
return m_lowbus_space->read_byte((addr & 0xff)+0x100);
}
void xavix_device::write_stack(uint32_t addr, uint8_t val)
{
// address is always 0x100-0x1ff
m_lowbus_space->write_byte((addr & 0xff)+0x100, val);
}
uint8_t xavix_device::read_zeropage(uint32_t addr)
{
// address is always 0x00-0xff
addr &= 0xff;
if (addr == 0xfe)
{
return m_codebank;
}
else if (addr == 0xff)
{
return m_databank;
}
return m_lowbus_space->read_byte(addr);
}
void xavix_device::write_zeropage(uint32_t addr, uint8_t val)
{
// address is always 0x00-0xff
addr &= 0xff;
if (addr == 0xfe)
{
m_codebank = val;
return;
}
else if (addr == 0xff)
{
m_databank = val;
return;
}
m_lowbus_space->write_byte(addr, val);
}
// data writes
inline void xavix_device::write_full_data(uint8_t databank, uint16_t adr, uint8_t val)
{
if (databank < 0x80)
{
if (adr < 0x8000)
{
if (adr == 0xfe)
{
m_codebank = val;
return;
}
else if (adr == 0xff)
{
m_databank = val;
return;
}
m_lowbus_space->write_byte(adr, val);
}
else
{
m_extbus_space->write_byte((databank << 16) | adr, val);
}
}
else
{
m_extbus_space->write_byte((databank << 16) | adr, val);
}
}
void xavix_device::mi_xavix::write(uint16_t adr, uint8_t val)
{
uint8_t databank = base->get_databank();
base->write_full_data(databank, adr, val);
}
void xavix_device::set_codebank(uint8_t bank)
{
// space().write_byte(0xfe, bank);
m_codebank = bank;
}
inline uint8_t xavix_device::get_codebank()
{
// return space().read_byte(0xfe);
return m_codebank;
}
inline void xavix_device::set_databank(uint8_t bank)
{
// space().write_byte(0xff, bank);
m_databank = bank;
}
inline uint8_t xavix_device::get_databank()
{
// return space().read_byte(0xff);
return m_databank;
}
device_memory_interface::space_config_vector xavix_device::memory_space_config() const
{
if(has_configured_map(AS_OPCODES))
return space_config_vector {
std::make_pair(AS_PROGRAM, &program_config),
std::make_pair(AS_OPCODES, &sprogram_config),
std::make_pair(5, &m_lowbus_config),
std::make_pair(6, &m_extbus_config)
};
else
return space_config_vector {
std::make_pair(AS_PROGRAM, &program_config),
std::make_pair(5, &m_lowbus_config),
std::make_pair(6, &m_extbus_config)
};
}
void xavix_device::state_import(const device_state_entry &entry)
{
m6502_device::state_import(entry);
switch(entry.index())
{
case XAVIX_DATABANK:
break;
case XAVIX_CODEBANK:
break;
}
}
void xavix_device::state_string_export(const device_state_entry &entry, std::string &str) const
{
m6502_device::state_string_export(entry, str);
switch(entry.index())
{
case XAVIX_DATABANK:
str = string_format("%02x", m_databank);
break;
case XAVIX_CODEBANK:
str = string_format("%02x", m_codebank);
break;
}
}
#include "cpu/m6502/xavix.hxx"
|