Skip to content

Commit 8bf993c

Browse files
authored
bus/pce: Moved Super System Card and Arcade Card to slot card devices. (#11726)
* Moved expansion card emulation out of the system into card devices. * Removed machine configuration settings for expansion settings. * Started to modernise the HuCard slot interface. New working software list items (pce.xml) ------------------------ Arcade Card Pro
1 parent bc857d2 commit 8bf993c

16 files changed

+689
-432
lines changed

hash/pce.xml

+13
Original file line numberDiff line numberDiff line change
@@ -4502,4 +4502,17 @@ https://mametesters.org/view.php?id=6597
45024502
</part>
45034503
</software>
45044504

4505+
<software name="acardpro">
4506+
<description>Arcade Card Pro</description>
4507+
<year>1994</year>
4508+
<publisher>NEC</publisher>
4509+
<part name="cart" interface="pce_cart">
4510+
<feature name="slot" value="acard_pro" />
4511+
<dataarea name="rom" size="262144">
4512+
<!-- TODO: same as scdsys? needs to verification -->
4513+
<rom name="[cd] super cd-rom system (japan) (v3.0).pce" size="262144" crc="6d9a73ef" sha1="79f5ff55dd10187c7fd7b8daab0b3ffbd1f56a2c" status="baddump" />
4514+
</dataarea>
4515+
</part>
4516+
</software>
4517+
45054518
</softwarelist>

hash/pcecd.xml

+34-34
Large diffs are not rendered by default.

scripts/src/bus.lua

+4
Original file line numberDiff line numberDiff line change
@@ -4257,6 +4257,10 @@ if (BUSES["PCE"]~=null) then
42574257
MAME_DIR .. "src/devices/bus/pce/pce_slot.h",
42584258
MAME_DIR .. "src/devices/bus/pce/pce_rom.cpp",
42594259
MAME_DIR .. "src/devices/bus/pce/pce_rom.h",
4260+
MAME_DIR .. "src/devices/bus/pce/pce_scdsys.cpp",
4261+
MAME_DIR .. "src/devices/bus/pce/pce_scdsys.h",
4262+
MAME_DIR .. "src/devices/bus/pce/pce_acard.cpp",
4263+
MAME_DIR .. "src/devices/bus/pce/pce_acard.h",
42604264
}
42614265
end
42624266

src/devices/bus/pce/pce_acard.cpp

+232
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
// license:BSD-3-Clause
2+
// copyright-holders:Fabio Priuli, Angelo Salese
3+
/***********************************************************************************************************
4+
5+
6+
PC-Engine Arcade Card emulation
7+
8+
TODO:
9+
- Proper Arcade Card Duo support
10+
11+
***********************************************************************************************************/
12+
13+
14+
#include "emu.h"
15+
#include "pce_acard.h"
16+
17+
18+
19+
//-------------------------------------------------
20+
// pce_acard_device - constructor
21+
//-------------------------------------------------
22+
23+
DEFINE_DEVICE_TYPE(PCE_ROM_ACARD_DUO, pce_acard_duo_device, "pce_acard_duo", "Arcade Card Duo")
24+
DEFINE_DEVICE_TYPE(PCE_ROM_ACARD_PRO, pce_acard_pro_device, "pce_acard_pro", "Arcade Card Pro")
25+
26+
27+
pce_acard_duo_device::pce_acard_duo_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock)
28+
: device_t(mconfig, type, tag, owner, clock)
29+
, device_pce_cart_interface( mconfig, *this )
30+
, m_ram(*this, "ram", 0x200000, ENDIANNESS_LITTLE)
31+
, m_shift(0)
32+
, m_shift_reg(0)
33+
, m_rotate_reg(0)
34+
{
35+
}
36+
37+
pce_acard_duo_device::pce_acard_duo_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
38+
: pce_acard_duo_device(mconfig, PCE_ROM_ACARD_DUO, tag, owner, clock)
39+
{
40+
}
41+
42+
pce_acard_pro_device::pce_acard_pro_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
43+
: pce_acard_duo_device(mconfig, PCE_ROM_ACARD_PRO, tag, owner, clock)
44+
, m_scdsys()
45+
{
46+
}
47+
48+
49+
//-------------------------------------------------
50+
// mapper specific start/reset
51+
//-------------------------------------------------
52+
53+
54+
void pce_acard_duo_device::device_start()
55+
{
56+
save_item(STRUCT_MEMBER(m_port, m_ctrl));
57+
save_item(STRUCT_MEMBER(m_port, m_base_addr));
58+
save_item(STRUCT_MEMBER(m_port, m_addr_offset));
59+
save_item(STRUCT_MEMBER(m_port, m_addr_inc));
60+
save_item(NAME(m_shift));
61+
save_item(NAME(m_shift_reg));
62+
save_item(NAME(m_rotate_reg));
63+
}
64+
65+
void pce_acard_pro_device::device_start()
66+
{
67+
pce_acard_duo_device::device_start();
68+
69+
m_scdsys.init(*this);
70+
m_scdsys.set_region(false);
71+
}
72+
73+
void pce_acard_duo_device::device_reset()
74+
{
75+
for (auto &port : m_port)
76+
{
77+
port.m_ctrl = 0;
78+
port.m_base_addr = 0;
79+
port.m_addr_offset = 0;
80+
port.m_addr_inc = 0;
81+
}
82+
m_shift = 0;
83+
m_shift_reg = 0;
84+
m_rotate_reg = 0;
85+
}
86+
87+
/*-------------------------------------------------
88+
mapper specific handlers
89+
-------------------------------------------------*/
90+
91+
void pce_acard_duo_device::install_memory_handlers(address_space &space)
92+
{
93+
space.install_readwrite_handler(0x080000, 0x087fff, emu::rw_delegate(*this, FUNC(pce_acard_duo_device::ram_r)), emu::rw_delegate(*this, FUNC(pce_acard_duo_device::ram_w)));
94+
// TODO: mirrored?
95+
space.install_readwrite_handler(0x1ffa00, 0x1ffaff, 0, 0x100, 0, emu::rw_delegate(*this, FUNC(pce_acard_duo_device::peripheral_r)), emu::rw_delegate(*this, FUNC(pce_acard_duo_device::peripheral_w)));
96+
}
97+
98+
void pce_acard_pro_device::install_memory_handlers(address_space &space)
99+
{
100+
space.install_rom(0x000000, 0x03ffff, 0x040000, m_rom); // TODO: underdumped or mirrored?
101+
space.install_ram(0x0d0000, 0x0fffff, m_scdsys.ram());
102+
space.install_read_handler(0x1ff8c0, 0x1ff8c7, 0, 0x130, 0, emu::rw_delegate(*this, FUNC(pce_acard_pro_device::register_r)));
103+
pce_acard_duo_device::install_memory_handlers(space);
104+
}
105+
106+
uint8_t pce_acard_duo_device::ram_r(offs_t offset)
107+
{
108+
return peripheral_r((offset & 0x6000) >> 9);
109+
}
110+
111+
void pce_acard_duo_device::ram_w(offs_t offset, uint8_t data)
112+
{
113+
peripheral_w((offset & 0x6000) >> 9, data);
114+
}
115+
116+
uint8_t pce_acard_duo_device::peripheral_r(offs_t offset)
117+
{
118+
if ((offset & 0xe0) == 0xe0)
119+
{
120+
switch (offset & 0x1f)
121+
{
122+
case 0x00: return (m_shift >> 0) & 0xff;
123+
case 0x01: return (m_shift >> 8) & 0xff;
124+
case 0x02: return (m_shift >> 16) & 0xff;
125+
case 0x03: return (m_shift >> 24) & 0xff;
126+
case 0x04: return m_shift_reg;
127+
case 0x05: return m_rotate_reg;
128+
case 0x1c: return 0x00;
129+
case 0x1d: return 0x00;
130+
case 0x1e: return 0x10; // Version number (MSB?)
131+
case 0x1f: return 0x51; // Arcade Card ID
132+
}
133+
134+
return 0xff;
135+
}
136+
137+
dram_port &port = m_port[(offset & 0x30) >> 4];
138+
139+
switch (offset & 0x8f)
140+
{
141+
case 0x00:
142+
case 0x01:
143+
{
144+
uint8_t const res = m_ram[port.ram_addr()];
145+
146+
if (!machine().side_effects_disabled())
147+
port.addr_increment();
148+
149+
return res;
150+
}
151+
case 0x02: return (port.m_base_addr >> 0) & 0xff;
152+
case 0x03: return (port.m_base_addr >> 8) & 0xff;
153+
case 0x04: return (port.m_base_addr >> 16) & 0xff;
154+
case 0x05: return (port.m_addr_offset >> 0) & 0xff;
155+
case 0x06: return (port.m_addr_offset >> 8) & 0xff;
156+
case 0x07: return (port.m_addr_inc >> 0) & 0xff;
157+
case 0x08: return (port.m_addr_inc >> 8) & 0xff;
158+
case 0x09: return port.m_ctrl;
159+
default: return 0xff;
160+
}
161+
}
162+
163+
void pce_acard_duo_device::peripheral_w(offs_t offset, uint8_t data)
164+
{
165+
if ((offset & 0xe0) == 0xe0)
166+
{
167+
switch (offset & 0x0f)
168+
{
169+
case 0: m_shift = (data & 0xff) | (m_shift & 0xffffff00); break;
170+
case 1: m_shift = (data << 8) | (m_shift & 0xffff00ff); break;
171+
case 2: m_shift = (data << 16) | (m_shift & 0xff00ffff); break;
172+
case 3: m_shift = (data << 24) | (m_shift & 0x00ffffff); break;
173+
case 4:
174+
m_shift_reg = data & 0x0f;
175+
176+
if (m_shift_reg != 0)
177+
{
178+
m_shift = (m_shift_reg < 8)
179+
? (m_shift << m_shift_reg)
180+
: (m_shift >> (16 - m_shift_reg));
181+
}
182+
break;
183+
case 5:
184+
m_rotate_reg = data & 0x0f;
185+
186+
if (m_rotate_reg != 0)
187+
{
188+
m_shift = (m_rotate_reg < 8)
189+
? ((m_shift << m_rotate_reg) | (m_shift >> (32 - m_rotate_reg)))
190+
: ((m_shift >> (16 - m_rotate_reg)) | (m_shift << (32 - (16 - m_rotate_reg))));
191+
}
192+
break;
193+
}
194+
}
195+
else
196+
{
197+
dram_port &port = m_port[(offset & 0x30) >> 4];
198+
199+
switch (offset & 0x8f)
200+
{
201+
case 0x00:
202+
case 0x01:
203+
m_ram[port.ram_addr()] = data;
204+
205+
port.addr_increment();
206+
break;
207+
208+
case 0x02: port.m_base_addr = (data & 0xff) | (port.m_base_addr & 0xffff00); break;
209+
case 0x03: port.m_base_addr = (data << 8) | (port.m_base_addr & 0xff00ff); break;
210+
case 0x04: port.m_base_addr = (data << 16) | (port.m_base_addr & 0x00ffff); break;
211+
case 0x05:
212+
port.m_addr_offset = (data & 0xff) | (port.m_addr_offset & 0xff00);
213+
214+
if ((port.m_ctrl & 0x60) == 0x20)
215+
port.adjust_addr();
216+
break;
217+
case 0x06:
218+
port.m_addr_offset = (data << 8) | (port.m_addr_offset & 0x00ff);
219+
220+
if ((port.m_ctrl & 0x60) == 0x40)
221+
port.adjust_addr();
222+
break;
223+
case 0x07: port.m_addr_inc = (data & 0xff) | (port.m_addr_inc & 0xff00); break;
224+
case 0x08: port.m_addr_inc = (data << 8) | (port.m_addr_inc & 0x00ff); break;
225+
case 0x09: port.m_ctrl = data & 0x7f; break;
226+
case 0x0a:
227+
if ((port.m_ctrl & 0x60) == 0x60)
228+
port.adjust_addr();
229+
break;
230+
}
231+
}
232+
}

src/devices/bus/pce/pce_acard.h

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// license:BSD-3-Clause
2+
// copyright-holders:Fabio Priuli, Angelo Salese
3+
#ifndef MAME_BUS_PCE_PCE_ACARD_H
4+
#define MAME_BUS_PCE_PCE_ACARD_H
5+
6+
#pragma once
7+
8+
#include "pce_scdsys.h"
9+
#include "pce_slot.h"
10+
11+
12+
// ======================> pce_acard_duo_device
13+
14+
class pce_acard_duo_device : public device_t,
15+
public device_pce_cart_interface
16+
{
17+
public:
18+
// construction/destruction
19+
pce_acard_duo_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
20+
21+
// reading and writing
22+
virtual void install_memory_handlers(address_space &space) override;
23+
24+
protected:
25+
// construction/destruction
26+
pce_acard_duo_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock);
27+
28+
// device-level overrides
29+
virtual void device_start() override;
30+
virtual void device_reset() override;
31+
32+
private:
33+
uint8_t ram_r(offs_t offset);
34+
void ram_w(offs_t offset, uint8_t data);
35+
uint8_t peripheral_r(offs_t offset);
36+
void peripheral_w(offs_t offset, uint8_t data);
37+
38+
/* Arcade Card specific */
39+
memory_share_creator<uint8_t> m_ram;
40+
41+
struct dram_port
42+
{
43+
uint32_t ram_addr()
44+
{
45+
if (BIT(m_ctrl, 1))
46+
return (m_base_addr + m_addr_offset + (BIT(m_ctrl, 3) ? 0xff0000 : 0)) & 0x1fffff;
47+
else
48+
return m_base_addr & 0x1fffff;
49+
}
50+
51+
void addr_increment()
52+
{
53+
if (BIT(m_ctrl, 0))
54+
{
55+
if (BIT(m_ctrl, 4))
56+
{
57+
m_base_addr += m_addr_inc;
58+
m_base_addr &= 0xffffff;
59+
}
60+
else
61+
{
62+
m_addr_offset += m_addr_inc;
63+
}
64+
}
65+
}
66+
67+
void adjust_addr()
68+
{
69+
m_base_addr += m_addr_offset + (BIT(m_ctrl, 3) ? 0xff0000 : 0);
70+
m_base_addr &= 0xffffff;
71+
}
72+
73+
uint8_t m_ctrl;
74+
uint32_t m_base_addr;
75+
uint16_t m_addr_offset;
76+
uint16_t m_addr_inc;
77+
};
78+
79+
dram_port m_port[4];
80+
uint32_t m_shift;
81+
uint8_t m_shift_reg;
82+
uint8_t m_rotate_reg;
83+
};
84+
85+
86+
// ======================> pce_acard_duo_device
87+
88+
class pce_acard_pro_device : public pce_acard_duo_device
89+
90+
{
91+
public:
92+
// construction/destruction
93+
pce_acard_pro_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
94+
95+
// reading and writing
96+
virtual void install_memory_handlers(address_space &space) override;
97+
98+
protected:
99+
virtual void device_start() override;
100+
101+
private:
102+
pce_scdsys_shared m_scdsys;
103+
104+
// reading
105+
uint8_t register_r(offs_t offset) { return m_scdsys.register_r(offset); }
106+
};
107+
108+
109+
// device type definition
110+
DECLARE_DEVICE_TYPE(PCE_ROM_ACARD_DUO, pce_acard_duo_device)
111+
DECLARE_DEVICE_TYPE(PCE_ROM_ACARD_PRO, pce_acard_pro_device)
112+
113+
114+
#endif // MAME_BUS_PCE_PCE_ACARD_H

0 commit comments

Comments
 (0)