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
|
// license:BSD-3-Clause
// copyright-holders:David Haywood, K.Wilkins
/*
TODO:
output support
*/
#include "emu.h"
#include "machine/namco68.h"
DEFINE_DEVICE_TYPE(NAMCOC68, namcoc68_device, "namcoc68", "Namco C68 I/O")
namcoc68_device::namcoc68_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, NAMCOC68, tag, owner, clock),
m_mcu(*this, "mcu"),
m_in_pb_cb(*this),
m_in_pc_cb(*this),
m_in_ph_cb(*this),
m_in_pdsw_cb(*this),
m_port_analog_in_cb{{*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}, {*this}},
m_port_dial_in_cb{{*this}, {*this}, {*this}, {*this}},
m_dp_in(*this),
m_dp_out(*this)
{
}
ROM_START( namcoc68 )
ROM_REGION( 0x8000, "mcu", 0 )
ROM_LOAD( "c68.bin", 0x000000, 0x008000, CRC(ca64550a) SHA1(38d1ad1b1287cadef0c999aff9357927315f8e6b) ) // usually position 3d, but device really needs a way to specify it
ROM_END
// C68 looks like a drop-in replacement for C65, so the port mappings must be scrambled in one instance, since this already has a multiplex on the port, assume here
READ8_MEMBER(namcoc68_device::c68_p5_r)
{
uint16_t ret = (m_in_ph_cb() << 8) | m_in_pb_cb();
if (m_player_mux)
{
return bitswap<8>(ret, 6, 8, 10, 12, 4, 2, 0, 14);
}
else
{
return bitswap<8>(ret, 7, 9, 11, 13, 5, 3, 1, 15);
}
}
READ8_MEMBER(namcoc68_device::mcuc_r)
{
uint8_t ret = m_in_pc_cb();
ret = bitswap<8>(ret, 3, 2, 1, 0, 7, 6, 5, 4);
return ret;
}
WRITE8_MEMBER(namcoc68_device::c68_p3_w)
{
m_player_mux = (data & 0x80) ? 1 : 0;
}
READ8_MEMBER(namcoc68_device::ack_mcu_vbl_r)
{
m_mcu->set_input_line(m37450_device::M3745X_INT1_LINE, CLEAR_LINE);
return 0;
}
READ8_MEMBER(namcoc68_device::dpram_byte_r)
{
return m_dp_in(offset);
}
WRITE8_MEMBER(namcoc68_device::dpram_byte_w)
{
m_dp_out(offset,data);
}
READ8_MEMBER(namcoc68_device::unk_r)
{
return 0x00;
}
void namcoc68_device::c68_default_am(address_map &map)
{
/* input ports and dips are mapped here */
map(0x2000, 0x2000).r(FUNC(namcoc68_device::mcudsw_r));
map(0x3000, 0x3000).r(FUNC(namcoc68_device::mcudi0_r));
map(0x3001, 0x3001).r(FUNC(namcoc68_device::mcudi1_r));
map(0x3002, 0x3002).r(FUNC(namcoc68_device::mcudi2_r));
map(0x3003, 0x3003).r(FUNC(namcoc68_device::mcudi3_r));
map(0x5000, 0x57ff).rw(FUNC(namcoc68_device::dpram_byte_r), FUNC(namcoc68_device::dpram_byte_w));
map(0x6000, 0x6fff).r(FUNC(namcoc68_device::ack_mcu_vbl_r)); // VBL ack
map(0x8000, 0xffff).rom().region("mcu", 0);
}
void namcoc68_device::device_add_mconfig(machine_config &config)
{
m3745x_device* device = &M37450(config, m_mcu, DERIVED_CLOCK(1, 1)); // ugly, needs modernizing
MCFG_M3745X_ADC14_CALLBACKS(READ8(*this, namcoc68_device, mcuan0_r), READ8(*this, namcoc68_device, mcuan1_r), READ8(*this, namcoc68_device, mcuan2_r), READ8(*this, namcoc68_device, mcuan3_r))
MCFG_M3745X_ADC58_CALLBACKS(READ8(*this, namcoc68_device, mcuan4_r), READ8(*this, namcoc68_device, mcuan5_r), READ8(*this, namcoc68_device, mcuan6_r), READ8(*this, namcoc68_device, mcuan7_r))
MCFG_M3745X_PORT3_CALLBACKS(READ8(*this, namcoc68_device, mcuc_r), WRITE8(*this, namcoc68_device, c68_p3_w)) // coins/test/service
MCFG_M3745X_PORT5_CALLBACKS(READ8(*this, namcoc68_device, c68_p5_r), NOOP) // muxed player 1/2
MCFG_M3745X_PORT6_CALLBACKS(READ8(*this, namcoc68_device, unk_r), NOOP) // unused in sgunner2
MCFG_DEVICE_PROGRAM_MAP(c68_default_am)
}
void namcoc68_device::device_resolve_objects()
{
m_in_pb_cb.resolve_safe(0xff);
m_in_pc_cb.resolve_safe(0xff);
m_in_ph_cb.resolve_safe(0xff);
m_in_pdsw_cb.resolve_safe(0xff);
for (auto &cb : m_port_analog_in_cb)
cb.resolve_safe(0xff);
for (auto &cb : m_port_dial_in_cb)
cb.resolve_safe(0xff);
m_dp_in.resolve_safe(0xff);
m_dp_out.resolve_safe();
}
void namcoc68_device::device_start()
{
}
void namcoc68_device::device_reset()
{
m_player_mux = 0;
}
const tiny_rom_entry *namcoc68_device::device_rom_region() const
{
return ROM_NAME(namcoc68);
}
|