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
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
/***************************************************************************
m6509.c
6502 with banking and extended address bus
***************************************************************************/
#include "emu.h"
#include "m6509.h"
const device_type M6509 = &device_creator<m6509_device>;
m6509_device::m6509_device(const machine_config &mconfig, std::string tag, device_t *owner, UINT32 clock) :
m6502_device(mconfig, M6509, "M6509", tag, owner, clock, "m6509", __FILE__), XPC(0), bank_i(0), bank_y(0)
{
program_config.m_addrbus_width = 20;
program_config.m_logaddr_width = 20;
sprogram_config.m_addrbus_width = 20;
sprogram_config.m_logaddr_width = 20;
}
void m6509_device::device_start()
{
if(direct_disabled)
mintf = new mi_6509_nd(this);
else
mintf = new mi_6509_normal(this);
init();
state_add(STATE_GENPC, "GENPC", 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;
}
void m6509_device::state_export(const device_state_entry &entry)
{
switch(entry.index()) {
case STATE_GENPC:
XPC = adr_in_bank_i(NPC);
break;
}
}
offs_t m6509_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
{
return disassemble_generic(buffer, pc, oprom, opram, options, disasm_entries);
}
m6509_device::mi_6509_normal::mi_6509_normal(m6509_device *_base)
{
base = _base;
}
UINT8 m6509_device::mi_6509_normal::read(UINT16 adr)
{
UINT8 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 m6509_device::mi_6509_normal::read_sync(UINT16 adr)
{
UINT8 res = sdirect->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 m6509_device::mi_6509_normal::read_arg(UINT16 adr)
{
UINT8 res = direct->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 m6509_device::mi_6509_normal::read_9(UINT16 adr)
{
UINT8 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 adr, UINT8 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 adr, UINT8 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 m6509_device::mi_6509_nd::read_sync(UINT16 adr)
{
UINT8 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 m6509_device::mi_6509_nd::read_arg(UINT16 adr)
{
UINT8 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.inc"
|