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
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
/***************************************************************************
m6509.c
6502 with banking and extended address bus
***************************************************************************/
#include "emu.h"
#include "m6509.h"
#include "m6509d.h"
DEFINE_DEVICE_TYPE(M6509, m6509_device, "m6509", "MOS Technology M6509")
m6509_device::m6509_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
m6502_device(mconfig, M6509, tag, owner, clock), bank_i(0), bank_y(0)
{
program_config.m_addr_width = 20;
program_config.m_logaddr_width = 20;
sprogram_config.m_addr_width = 20;
sprogram_config.m_logaddr_width = 20;
}
void m6509_device::device_start()
{
if(cache_disabled)
mintf = std::make_unique<mi_6509_nd>(this);
else
mintf = std::make_unique<mi_6509_normal>(this);
init();
state_add(STATE_GENPC, "GENPC", XPC).callexport().noshow();
state_add(STATE_GENPCBASE, "CURPC", XPC).callexport().noshow();
state_add(M6509_BI, "BI", bank_i);
state_add(M6509_BY, "BY", bank_y);
}
void m6509_device::device_reset()
{
m6502_device::device_reset();
bank_i = 0x0f;
bank_y = 0x0f;
}
offs_t m6509_device::pc_to_external(u16 pc)
{
return adr_in_bank_i(pc);
}
std::unique_ptr<util::disasm_interface> m6509_device::create_disassembler()
{
return std::make_unique<m6509_disassembler>();
}
m6509_device::mi_6509_normal::mi_6509_normal(m6509_device *_base)
{
base = _base;
}
uint8_t m6509_device::mi_6509_normal::read(uint16_t adr)
{
uint8_t res = program->read_byte(base->adr_in_bank_i(adr));
if(adr == 0x0000)
res = base->bank_i_r();
else if(adr == 0x0001)
res = base->bank_y_r();
return res;
}
uint8_t m6509_device::mi_6509_normal::read_sync(uint16_t adr)
{
uint8_t res = scache->read_byte(base->adr_in_bank_i(adr));
if(adr == 0x0000)
res = base->bank_i_r();
else if(adr == 0x0001)
res = base->bank_y_r();
return res;
}
uint8_t m6509_device::mi_6509_normal::read_arg(uint16_t adr)
{
uint8_t res = cache->read_byte(base->adr_in_bank_i(adr));
if(adr == 0x0000)
res = base->bank_i_r();
else if(adr == 0x0001)
res = base->bank_y_r();
return res;
}
uint8_t m6509_device::mi_6509_normal::read_9(uint16_t adr)
{
uint8_t res = program->read_byte(base->adr_in_bank_y(adr));
if(adr == 0x0000)
res = base->bank_i_r();
else if(adr == 0x0001)
res = base->bank_y_r();
return res;
}
void m6509_device::mi_6509_normal::write(uint16_t adr, uint8_t val)
{
program->write_byte(base->adr_in_bank_i(adr), val);
if(adr == 0x0000)
base->bank_i_w(val);
else if(adr == 0x0001)
base->bank_y_w(val);
}
void m6509_device::mi_6509_normal::write_9(uint16_t adr, uint8_t val)
{
program->write_byte(base->adr_in_bank_y(adr), val);
if(adr == 0x0000)
base->bank_i_w(val);
else if(adr == 0x0001)
base->bank_y_w(val);
}
m6509_device::mi_6509_nd::mi_6509_nd(m6509_device *_base) : mi_6509_normal(_base)
{
}
uint8_t m6509_device::mi_6509_nd::read_sync(uint16_t adr)
{
uint8_t res = sprogram->read_byte(base->adr_in_bank_i(adr));
if(adr == 0x0000)
res = base->bank_i_r();
else if(adr == 0x0001)
res = base->bank_y_r();
return res;
}
uint8_t m6509_device::mi_6509_nd::read_arg(uint16_t adr)
{
uint8_t res = program->read_byte(base->adr_in_bank_i(adr));
if(adr == 0x0000)
res = base->bank_i_r();
else if(adr == 0x0001)
res = base->bank_y_r();
return res;
}
#include "cpu/m6502/m6509.hxx"
|