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
|
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/***********************************************************************************************************
PC-Engine & Turbografx-16 cart emulation
***********************************************************************************************************/
#include "emu.h"
#include "pce_rom.h"
//-------------------------------------------------
// pce_rom_device - constructor
//-------------------------------------------------
const device_type PCE_ROM_STD = device_creator<pce_rom_device>;
const device_type PCE_ROM_CDSYS3 = device_creator<pce_cdsys3_device>;
const device_type PCE_ROM_POPULOUS = device_creator<pce_populous_device>;
const device_type PCE_ROM_SF2 = device_creator<pce_sf2_device>;
pce_rom_device::pce_rom_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)
: device_t(mconfig, type, name, tag, owner, clock, shortname, source),
device_pce_cart_interface( mconfig, *this )
{
}
pce_rom_device::pce_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, PCE_ROM_STD, "PCE & TG16 Carts", tag, owner, clock, "pce_rom", __FILE__),
device_pce_cart_interface( mconfig, *this )
{
}
pce_cdsys3_device::pce_cdsys3_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: pce_rom_device(mconfig, PCE_ROM_CDSYS3, "PCE & TG16 CD-System Cart v3.00", tag, owner, clock, "pce_cdsys3", __FILE__)
{
}
pce_populous_device::pce_populous_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: pce_rom_device(mconfig, PCE_ROM_POPULOUS, "PCE Populous Cart", tag, owner, clock, "pce_populous", __FILE__)
{
}
pce_sf2_device::pce_sf2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: pce_rom_device(mconfig, PCE_ROM_SF2, "PCE Street Fighters 2 Cart", tag, owner, clock, "pce_sf2", __FILE__), m_bank_base(0)
{
}
//-------------------------------------------------
// mapper specific start/reset
//-------------------------------------------------
void pce_sf2_device::device_start()
{
save_item(NAME(m_bank_base));
}
void pce_sf2_device::device_reset()
{
m_bank_base = 0;
}
/*-------------------------------------------------
mapper specific handlers
-------------------------------------------------*/
READ8_MEMBER(pce_rom_device::read_cart)
{
int bank = offset / 0x20000;
return m_rom[rom_bank_map[bank] * 0x20000 + (offset & 0x1ffff)];
}
READ8_MEMBER(pce_cdsys3_device::read_cart)
{
int bank = offset / 0x20000;
if (!m_ram.empty() && offset >= 0xd0000)
return m_ram[offset - 0xd0000];
return m_rom[rom_bank_map[bank] * 0x20000 + (offset & 0x1ffff)];
}
WRITE8_MEMBER(pce_cdsys3_device::write_cart)
{
if (!m_ram.empty() && offset >= 0xd0000)
m_ram[offset - 0xd0000] = data;
}
READ8_MEMBER(pce_populous_device::read_cart)
{
int bank = offset / 0x20000;
if (!m_ram.empty() && offset >= 0x80000 && offset < 0x88000)
return m_ram[offset & 0x7fff];
return m_rom[rom_bank_map[bank] * 0x20000 + (offset & 0x1ffff)];
}
WRITE8_MEMBER(pce_populous_device::write_cart)
{
if (!m_ram.empty() && offset >= 0x80000 && offset < 0x88000)
m_ram[offset & 0x7fff] = data;
}
READ8_MEMBER(pce_sf2_device::read_cart)
{
if (offset < 0x80000)
return m_rom[offset];
else
return m_rom[0x80000 + m_bank_base * 0x80000 + (offset & 0x7ffff)];
}
WRITE8_MEMBER(pce_sf2_device::write_cart)
{
if (offset >= 0x1ff0 && offset < 0x1ff4)
m_bank_base = offset & 3;
}
|