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
|
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
/***************************************************************************
m6510.c
6502 with 6 i/o pins, also known as 8500
***************************************************************************/
#include "emu.h"
#include "m6510.h"
const device_type M6510 = &device_creator<m6510_device>;
m6510_device::m6510_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
m6502_device(mconfig, M6510, "M6510", tag, owner, clock, "m6510", __FILE__),
read_port(*this),
write_port(*this), dir(0), port(0), drive(0)
{
pullup = 0x00;
floating = 0x00;
}
m6510_device::m6510_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, uint32_t clock, const char *shortname, const char *source) :
m6502_device(mconfig, type, name, tag, owner, clock, shortname, source),
read_port(*this),
write_port(*this), dir(0), port(0), drive(0)
{
pullup = 0x00;
floating = 0x00;
}
void m6510_device::set_pulls(uint8_t _pullup, uint8_t _floating)
{
pullup = _pullup;
floating = _floating;
}
offs_t m6510_device::disasm_disassemble(std::ostream &stream, offs_t pc, const uint8_t *oprom, const uint8_t *opram, uint32_t options)
{
return disassemble_generic(stream, pc, oprom, opram, options, disasm_entries);
}
void m6510_device::device_start()
{
read_port.resolve_safe(0);
write_port.resolve_safe();
if(direct_disabled)
mintf = new mi_6510_nd(this);
else
mintf = new mi_6510_normal(this);
init();
save_item(NAME(pullup));
save_item(NAME(floating));
save_item(NAME(dir));
save_item(NAME(port));
save_item(NAME(drive));
}
void m6510_device::device_reset()
{
m6502_device::device_reset();
dir = 0x00;
port = 0x00;
drive = 0x00;
update_port();
}
void m6510_device::update_port()
{
drive = (port & dir) | (drive & ~dir);
write_port((port & dir) | (pullup & ~dir));
}
uint8_t m6510_device::get_port()
{
return (port & dir) | (pullup & ~dir);
}
uint8_t m6510_device::dir_r()
{
return dir;
}
uint8_t m6510_device::port_r()
{
return ((read_port() | (floating & drive)) & ~dir) | (port & dir);
}
void m6510_device::dir_w(uint8_t data)
{
dir = data;
update_port();
}
void m6510_device::port_w(uint8_t data)
{
port = data;
update_port();
}
m6510_device::mi_6510_normal::mi_6510_normal(m6510_device *_base)
{
base = _base;
}
uint8_t m6510_device::mi_6510_normal::read(uint16_t adr)
{
uint8_t res = program->read_byte(adr);
if(adr == 0x0000)
res = base->dir_r();
else if(adr == 0x0001)
res = base->port_r();
return res;
}
uint8_t m6510_device::mi_6510_normal::read_sync(uint16_t adr)
{
uint8_t res = sdirect->read_byte(adr);
if(adr == 0x0000)
res = base->dir_r();
else if(adr == 0x0001)
res = base->port_r();
return res;
}
uint8_t m6510_device::mi_6510_normal::read_arg(uint16_t adr)
{
uint8_t res = direct->read_byte(adr);
if(adr == 0x0000)
res = base->dir_r();
else if(adr == 0x0001)
res = base->port_r();
return res;
}
void m6510_device::mi_6510_normal::write(uint16_t adr, uint8_t val)
{
program->write_byte(adr, val);
if(adr == 0x0000)
base->dir_w(val);
else if(adr == 0x0001)
base->port_w(val);
}
m6510_device::mi_6510_nd::mi_6510_nd(m6510_device *_base) : mi_6510_normal(_base)
{
}
uint8_t m6510_device::mi_6510_nd::read_sync(uint16_t adr)
{
uint8_t res = sprogram->read_byte(adr);
if(adr == 0x0000)
res = base->dir_r();
else if(adr == 0x0001)
res = base->port_r();
return res;
}
uint8_t m6510_device::mi_6510_nd::read_arg(uint16_t adr)
{
uint8_t res = program->read_byte(adr);
if(adr == 0x0000)
res = base->dir_r();
else if(adr == 0x0001)
res = base->port_r();
return res;
}
#include "cpu/m6502/m6510.hxx"
|